We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20865
    • 30 Posts
    MODx Revolution 2.0.5-pl (traditional).
    Please tell me what things I need to do in order to recognize a user as logged in person?
    It needs to work with login.login and login.profie(and updateprofile too).
    I have a single-login button with auto-registration, so I can authorize users just using the uid that integrated site returns me.
    Registration is already made, but now I need to authorize a person when it has finished registration, and I don’t know how to do this.
    Thanks for answering =)
      • 20865
      • 30 Posts
      UP. No ideas at all?

      I need to authorize a user without a password.
        • 3749
        • 24,544 Posts
        For security reasons, the usual method is to redirect the user to the login page (assuming that your auto-registration creates the user in the MODX DB). I can’t think of any easy way to do what you’re suggesting.

        You might be able to create code based on the Login snippet that performs the login operations without presenting a form.
          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
          • 20865
          • 30 Posts
          All I need is only make "fake" session. I can recognize a user that is trying to login, but I don’t know how to make right session context.
            • 20865
            • 30 Posts
            This I was looking for.
            So all I need to do is only fill $_SESSION with this arguments
            array (
                'loggedIn' => true,
                'id' => User Id, (internal key)
                'username' => User Name,
                'usertype' => (web|manager)
            )
            

            But there is a question of how to fill $_SESSION[’webValidated’]. It must be true, but how it actually validates...

            How Login.Login fills that info in session?
            [id] => 42 [username] => tester_30 [loggedIn] => 1 [webShortname] => tester_30 [webFullname] => Tester [webEmail] => [email protected] [webValidated] => 1 [webInternalKey] => 42 [webValid] => OGU2MDdhNDc1MmZhMmU1OTQxM2U1NzkwNTM2ZjJiNDI= [webUser] => dGVzdGVyXzMw [webFailedlogins] => 0 [webLastlogin] => 1306152615 [webnrlogins] => 16 [webUserGroupNames] => ) 

            I need to do "$login->executeProcessor" ?
            OnBeforeWebLogin returns only true\false or also any info about a user?
              • 20865
              • 30 Posts
              2 BobRay
              It is possible to authorize a user without a password. For beta I’m just using a username for authorization, but later I will have my own checks that will make this way more secure(also it is based on complete security of the integrated site and of the process on exchanging data. But if it is not secure - it is not my trouble).

              So the basic method is
                
              /* part from Login.Login. */
              $login = $modx->getService('login','Login',$corePath.'model/login/',$scriptProperties);
              if (!is_object($login) || !($login instanceof Login)) return '';
              $loginContext = $modx->context->get('key');
              /* running the login process */
              $response = $login->executeProcessor(array(
                  'action' => 'login',
                  'location' => 'security',
                  'login_context' => $loginContext,
                  'rememberme' => true,
                  'mycheck' => true, // my additional variable, that is used to skip modx original validation
                  'username' => 'tester_30' // later this will be a $username, that will be picked by uid from OpenID-service
                  ));
              

              And there(core->model->modx->processors->security->login.php) must be checks after each $rt = $modx->invokeEvent("OnBeforeWebLogin", $onBeforeLoginParams);
              There are only 2 of them, and you need to make $rt value true, so :
              else {
                  $rt = $modx->invokeEvent("OnBeforeWebLogin", $onBeforeLoginParams);
                  if($scriptProperties['mycheck']) {$rt[] = true;}
              }
              

              this will make all modx checks be passed by default if you have set mycheck.
                • 3749
                • 24,544 Posts
                Thanks for reporting this. I’m sure it will be a big help to others for things like LDAP authentication.
                  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