We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7045
    • 225 Posts
    I decided to test the login and register snippets on a site I have been working on, as it had been a while since I last tested. Once I register and click on the link in the confirmation email, I get redirected to the home page. This is correct behavior. However, when I click the link to login, I get redirected to the page that has my logout chunk.

    The system appears to have me logged in as (Anonymous), which would make sense to be redirected to the logout chunk if the system thinks I am already logged in. Anon can't do anything but "load", but this doesn't seemed correct.

    This has never happened. I check my perms, cleared cache, flushed perms, flushed sessions, used a different browser, etc.
      • 3749
      • 24,544 Posts
      When you confirm registration, the ConfirmRegister snippet logs you in.

      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 7045
        • 225 Posts
        It logs me in as (Anonymous) though. That is what personalize shows me. Also, when I try to access the profile page, it shows it as secure. That makes sense if I am indeed logged as Anon.

        So I go to the login page, it of course redirects me to my logout page. Now I can login as a secure uses and access the secured resources.
          • 1778
          • 659 Posts
          I noticed this behavior too...
          ConfirmRegister seems to log the user in but just a part of him... You can not access any info from the user (neither name, id, nor profile infos)... It seems the authenticate part is a bit buggy...
          The only way I found to workaround is to set 'authenticate' to false and on my Confirm register page put a message and a link to redirect on 'your first connection on the site...' page....
          Neither very efficient nor very 'modern' but since authentication works as expected it will do the trick
          Cheers
            • 7045
            • 225 Posts
            Thank you, thank you, thank you, I though I was going crazy or did something very minor that was going to require hours of troubleshooting to fix. I guess I feel a little better now.

            I also appreciate you posting your work-around. I think I will try something similar until the bug is worked out.
              • 3749
              • 24,544 Posts
              @anso. Good to know. I think ConfirmRegister is supposed to log you in as yourself, so that may be a bug.

              ---------------------------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 20618
                • 7 Posts
                Indeed, the ConfirmRegister snippet will automaticly login as anonymous.
                Is this already reported as a bug? If so what is the status?

                MODx 2.2.0-pl2 - Login (ConfirmRegister) 1.7.3-pl
                  • 3749
                  • 24,544 Posts
                  I can't find it, so I don't think it's been reported.

                  BTW, are you using FURLs? There was an earlier bug that only affected non-FURL sites.


                  ---------------------------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
                  MODX info for everyone: http://bobsguides.com/modx.html
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 20618
                    • 7 Posts
                    Yes the website is using FURLs. For the moment i turned off authentication when activating.
                    But its more proffesional to have it automaticly log in.
                      • 3749
                      • 24,544 Posts
                      It's odd because ConfirmRegister gets the user successfully from the DB (otherwise the activation would fail), then logs them in with this code:


                      /**
                           * Login the user to the specified contexts
                           * @return void
                           */
                          public function addSessionContexts() {
                              if ($this->getProperty('authenticate',true,'isset')) {
                                  $this->modx->user =& $user;
                                  $this->modx->getUser();
                                  $contexts = $this->getProperty('authenticateContexts',$this->modx->context->get('key'));
                                  $contexts = explode(',',$contexts);
                                  foreach ($contexts as $ctx) {
                                      $this->modx->user->addSessionContext($ctx);
                                  }
                              }
                          }


                      You might try changing:

                      $this->modx->user =& $user;


                      to

                      $this->modx->user =& $this->user;


                      In the ConfirmRegister controller (core/components/login/controllers/web/ConfirmRegister.php)



                      ---------------------------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
                      MODX info for everyone: http://bobsguides.com/modx.html
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting