protected function _actionTokenlogin(AnCommandContext $context)
    {
        if ($this->token == '') {
            throw new AnErrorException(array('No token is provided'), AnHttpResponse::FORBIDDEN);
        }

        $person = $this->getService('repos:people.person')->find(array('activationCode' => $this->token));

        if (! $person) {
            throw new AnErrorException(array('This token is invalid'), AnHttpResponse::NOT_FOUND);
        }

        $newPerson = ($person->registrationDate->compare($person->lastVisitDate)) ? true : false;

        if ($newPerson) {
            $person->enable();
        }

        $person->activationCode = '';
        $this->token = '';
        $this->_request->token = '';

        if ($this->reset_password) {
            AnRequest::set('session.reset_password_prompt', 1);
        }

        $credentials = array(
            'username' => $person->username,
            'password' => $person->password
        );

        dispatch_plugin('user.onBeforeLoginPerson', array('credentials' => $credentials));

        $this->getService('com:people.helper.person')->login($credentials);

        dispatch_plugin('user.onAfterLoginPerson', array('person' => $person));

        if ($this->return) {
            AnRequest::set('session.return', $this->return);
            $returnUrl = base64UrlDecode($this->return);
            $this->getResponse()->setRedirect($returnUrl);
        } else {
            unset($_SESSION['return']);
            if ($this->_request->isFirstPerson) {
                $this->setMessage(sprintf(translate('COM-PEOPLE-PROMPT-WELCOME-SUPERADMIN'), $person->name));
            } else {
                $this->setMessage('COM-PEOPLE-PROMPT-UPDATE-PASSWORD');
            }
            $this->getResponse()->setRedirect(route($person->getURL().'&get=settings&edit=account'));
        }

        $this->getResponse()->status = AnHttpResponse::ACCEPTED;

        return true;
    }
protected function _actionTokenlogin(AnCommandContext $context)
    {
        if ($this->token == '') {
            throw new AnErrorException(array('No token is provided'), AnHttpResponse::FORBIDDEN);
        }

        $person = $this->getService('repos:people.person')->find(array('activationCode' => $this->token));

        if (! $person) {
            throw new AnErrorException(array('This token is invalid'), AnHttpResponse::NOT_FOUND);
        }

        $newPerson = ($person->registrationDate->compare($person->lastVisitDate)) ? true : false;

        if ($newPerson) {
            $person->enable();
        }

        $person->activationCode = '';
        $this->token = '';
        $this->_request->token = '';

        if ($this->reset_password) {
            AnRequest::set('session.reset_password_prompt', 1);
        }

        $credentials = array(
            'username' => $person->username,
            'password' => $person->password
        );

        dispatch_plugin('user.onBeforeLoginPerson', array('credentials' => $credentials));

        $this->getService('com:people.helper.person')->login($credentials);

        dispatch_plugin('user.onAfterLoginPerson', array('person' => $person));

        if ($this->return) {
            AnRequest::set('session.return', $this->return);
            $returnUrl = base64UrlDecode($this->return);
            $this->getResponse()->setRedirect($returnUrl);
        } else {
            unset($_SESSION['return']);
            if ($this->_request->isFirstPerson) {
                $this->setMessage(sprintf(translate('COM-PEOPLE-PROMPT-WELCOME-SUPERADMIN'), $person->name));
            } else {
                $this->setMessage('COM-PEOPLE-PROMPT-UPDATE-PASSWORD');
            }
            $this->getResponse()->setRedirect(route($person->getURL().'&get=settings&edit=account'));
        }

        $this->getResponse()->status = AnHttpResponse::ACCEPTED;

        return true;
    }
protected function _actionTokenlogin ( AnCommandContext $ context ) { if ( $ this -> token == '' ) { throw new AnErrorException ( array ( 'No token is provided' ) , AnHttpResponse :: FORBIDDEN ) ; } $ person = $ this -> getService ( 'repos:people.person' ) -> find ( array ( 'activationCode' => $ this -> token ) ) ; if ( ! $ person ) { throw new AnErrorException ( array ( 'This token is invalid' ) , AnHttpResponse :: NOT_FOUND ) ; } $ newPerson = ( $ person -> registrationDate -> compare ( $ person -> lastVisitDate ) ) ? true : false ; if ( $ newPerson ) { $ person -> enable ( ) ; } $ person -> activationCode = '' ; $ this -> token = '' ; $ this -> _request -> token = '' ; if ( $ this -> reset_password ) { AnRequest :: set ( 'session.reset_password_prompt' , 1 ) ; } $ credentials = array ( 'username' => $ person -> username , 'password' => $ person -> password ) ; dispatch_plugin ( 'user.onBeforeLoginPerson' , array ( 'credentials' => $ credentials ) ) ; $ this -> getService ( 'com:people.helper.person' ) -> login ( $ credentials ) ; dispatch_plugin ( 'user.onAfterLoginPerson' , array ( 'person' => $ person ) ) ; if ( $ this -> return ) { AnRequest :: set ( 'session.return' , $ this -> return ) ; $ returnUrl = base64UrlDecode ( $ this -> return ) ; $ this -> getResponse ( ) -> setRedirect ( $ returnUrl ) ; } else { unset ( $ _SESSION [ 'return' ] ) ; if ( $ this -> _request -> isFirstPerson ) { $ this -> setMessage ( sprintf ( translate ( 'COM-PEOPLE-PROMPT-WELCOME-SUPERADMIN' ) , $ person -> name ) ) ; } else { $ this -> setMessage ( 'COM-PEOPLE-PROMPT-UPDATE-PASSWORD' ) ; } $ this -> getResponse ( ) -> setRedirect ( route ( $ person -> getURL ( ) . '&get=settings&edit=account' ) ) ; } $ this -> getResponse ( ) -> status = AnHttpResponse :: ACCEPTED ; return true ; }
Logs in a user if an activation token is provided.

@param AnCommandContext $context Command chain context

@return bool true on success
Logs in a user if an activation token is provided .