We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31621
    • 23 Posts
    I have the following code and would appreciate if someone could tell me if modx is providing me any values. I have used ModX out-of-the-box most of the times and I'm developing for the first time.

    Any feedback will be appreciated.

    $eventName =  $modx->event->name;
    
    $secret = 'Test';
    $glueCode = 'Path/plugins/auth.remote/glueCode.php';
    $glueCodeFound = @is_file($glueCode);
    $autoCreate = 'true';
    $modx->log('here1');
    if(!$glueCodeFound) return;
    $modx->log('here2');
    
    switch ($eventName) {
        case 'OnManagerLogin':
        case 'OnWebLogin':
           // do something for authenticate
           $username = $modx->user->get('username');
           $user_pass = $modx->user->get('password');
    		
           global $AJXP_GLUE_GLOBALS;
           $AJXP_GLUE_GLOBALS = array();
           //$plugInAction, $login, $result, $secret, $autoCreate;
           $AJXP_GLUE_GLOBALS["secret"] = $secret;
           $AJXP_GLUE_GLOBALS["autoCreate"] = $autoCreate;
           $AJXP_GLUE_GLOBALS["plugInAction"] = "login";
           $AJXP_GLUE_GLOBALS["login"] = array("name"=>$username, "password"=>$user_pass);  		
           include($glueCode);
           break;
        case 'OnUserActivate':
        case 'OnUserSave':
           // do something for createUser
           $username = $modx->user->get('username');
           $user_pass = $modx->user->get('password');
           global $AJXP_GLUE_GLOBALS;
           $AJXP_GLUE_GLOBALS = array();
           //global $plugInAction, $result, $secret, $user;
           $AJXP_GLUE_GLOBALS["secret"] = $secret;
    
           $AJXP_GLUE_GLOBALS["user"] = array();
           $AJXP_GLUE_GLOBALS["user"]['name']	= $username ;
           $AJXP_GLUE_GLOBALS["user"]['password']	= $user_pass;
           $AJXP_GLUE_GLOBALS["user"]['right'] = ($modx->user->get('id') == 1?'admin':'');	
           $AJXP_GLUE_GLOBALS["plugInAction"] = ($modx->user->get('mode') == "new"?"addUser":"updateUser");
           include($glueCode);
           break;
    }
    return;
    


    This is on Modx Revolution 2.2.4-pl

    Questions:

    • Would this provide the necessary details to the Ajaxplorer to allow a user to login?
    • Does the above code execute after the code code for the System Event of before the event?

    As of now, with the above code, after successful login, when I try to navigate to the Ajaxplorer I'm redirected to my login page and I guess that is due to the credentials not being passed correctly.
      • 2371
      • 29 Posts
      I would be glad if you came with MODX Revolution, but it would be happier in twins from AjaXplorer communication with MODX Evolution wink