public function setAdminRecoveryData($loggingInAs, $returnTo = '')
    {
        $oSession = Factory::service('Session', 'nails/module-auth');
        $oInput   = Factory::service('Input');
        //  Look for existing Recovery Data
        $existingRecoveryData = $oSession->getUserData($this->sAdminRecoveryField);

        if (empty($existingRecoveryData)) {

            $existingRecoveryData = [];
        }

        //  Prepare the new element
        $adminRecoveryData            = new \stdClass();
        $adminRecoveryData->oldUserId = activeUser('id');
        $adminRecoveryData->newUserId = $loggingInAs;
        $adminRecoveryData->hash      = md5(activeUser('password'));
        $adminRecoveryData->name      = activeUser('first_name,last_name');
        $adminRecoveryData->email     = activeUser('email');
        $adminRecoveryData->returnTo  = empty($returnTo) ? $oInput->server('REQUEST_URI') : $returnTo;

        $adminRecoveryData->loginUrl = 'auth/override/login_as/';
        $adminRecoveryData->loginUrl .= md5($adminRecoveryData->oldUserId) . '/' . $adminRecoveryData->hash;
        $adminRecoveryData->loginUrl .= '?returningAdmin=1';
        $adminRecoveryData->loginUrl = site_url($adminRecoveryData->loginUrl);

        //  Put the new session onto the stack and save to the session
        $existingRecoveryData[] = $adminRecoveryData;

        $oSession->setUserData($this->sAdminRecoveryField, $existingRecoveryData);
    }
public function setAdminRecoveryData($loggingInAs, $returnTo = '')
    {
        $oSession = Factory::service('Session', 'nails/module-auth');
        $oInput   = Factory::service('Input');
        //  Look for existing Recovery Data
        $existingRecoveryData = $oSession->getUserData($this->sAdminRecoveryField);

        if (empty($existingRecoveryData)) {

            $existingRecoveryData = [];
        }

        //  Prepare the new element
        $adminRecoveryData            = new \stdClass();
        $adminRecoveryData->oldUserId = activeUser('id');
        $adminRecoveryData->newUserId = $loggingInAs;
        $adminRecoveryData->hash      = md5(activeUser('password'));
        $adminRecoveryData->name      = activeUser('first_name,last_name');
        $adminRecoveryData->email     = activeUser('email');
        $adminRecoveryData->returnTo  = empty($returnTo) ? $oInput->server('REQUEST_URI') : $returnTo;

        $adminRecoveryData->loginUrl = 'auth/override/login_as/';
        $adminRecoveryData->loginUrl .= md5($adminRecoveryData->oldUserId) . '/' . $adminRecoveryData->hash;
        $adminRecoveryData->loginUrl .= '?returningAdmin=1';
        $adminRecoveryData->loginUrl = site_url($adminRecoveryData->loginUrl);

        //  Put the new session onto the stack and save to the session
        $existingRecoveryData[] = $adminRecoveryData;

        $oSession->setUserData($this->sAdminRecoveryField, $existingRecoveryData);
    }
public function setAdminRecoveryData ( $ loggingInAs , $ returnTo = '' ) { $ oSession = Factory :: service ( 'Session' , 'nails/module-auth' ) ; $ oInput = Factory :: service ( 'Input' ) ; //  Look for existing Recovery Data $ existingRecoveryData = $ oSession -> getUserData ( $ this -> sAdminRecoveryField ) ; if ( empty ( $ existingRecoveryData ) ) { $ existingRecoveryData = [ ] ; } //  Prepare the new element $ adminRecoveryData = new \ stdClass ( ) ; $ adminRecoveryData -> oldUserId = activeUser ( 'id' ) ; $ adminRecoveryData -> newUserId = $ loggingInAs ; $ adminRecoveryData -> hash = md5 ( activeUser ( 'password' ) ) ; $ adminRecoveryData -> name = activeUser ( 'first_name,last_name' ) ; $ adminRecoveryData -> email = activeUser ( 'email' ) ; $ adminRecoveryData -> returnTo = empty ( $ returnTo ) ? $ oInput -> server ( 'REQUEST_URI' ) : $ returnTo ; $ adminRecoveryData -> loginUrl = 'auth/override/login_as/' ; $ adminRecoveryData -> loginUrl .= md5 ( $ adminRecoveryData -> oldUserId ) . '/' . $ adminRecoveryData -> hash ; $ adminRecoveryData -> loginUrl .= '?returningAdmin=1' ; $ adminRecoveryData -> loginUrl = site_url ( $ adminRecoveryData -> loginUrl ) ; //  Put the new session onto the stack and save to the session $ existingRecoveryData [ ] = $ adminRecoveryData ; $ oSession -> setUserData ( $ this -> sAdminRecoveryField , $ existingRecoveryData ) ; }
Adds to the admin recovery array, allowing suers to login as other users multiple times, and come back

@param integer $loggingInAs The ID of the user who is being imitated
@param string  $returnTo    Where to redirect the user when they log back in
Adds to the admin recovery array allowing suers to login as other users multiple times and come back