src/apis/UserController.php
public function actionChangeEmail()
    {
        $token = Yii::$app->request->getBodyParam('token');
        $user = Yii::$app->adminuser->identity;
        
        if (!empty($token) && sha1($token) == $user->email_verification_token && $this->hasOpenEmailValidation($user)) {
            $newEmail = $user->setting->get(User::USER_SETTING_NEWUSEREMAIL);
            
            $user->email = $newEmail;
            if ($user->update(true, ['email'])) {
                $user->resetEmailVerification();
                $newEmail = $user->setting->remove(User::USER_SETTING_NEWUSEREMAIL);
                return ['success' => true];
            } else {
                return $this->sendModelError($user);
            }
        }
        
        return $this->sendArrayError(['email' => Module::t('account_changeemail_wrongtokenorempty')]);
    }
public function actionChangeEmail()
    {
        $token = Yii::$app->request->getBodyParam('token');
        $user = Yii::$app->adminuser->identity;
        
        if (!empty($token) && sha1($token) == $user->email_verification_token && $this->hasOpenEmailValidation($user)) {
            $newEmail = $user->setting->get(User::USER_SETTING_NEWUSEREMAIL);
            
            $user->email = $newEmail;
            if ($user->update(true, ['email'])) {
                $user->resetEmailVerification();
                $newEmail = $user->setting->remove(User::USER_SETTING_NEWUSEREMAIL);
                return ['success' => true];
            } else {
                return $this->sendModelError($user);
            }
        }
        
        return $this->sendArrayError(['email' => Module::t('account_changeemail_wrongtokenorempty')]);
    }
public function actionChangeEmail ( ) { $ token = Yii :: $ app -> request -> getBodyParam ( 'token' ) ; $ user = Yii :: $ app -> adminuser -> identity ; if ( ! empty ( $ token ) && sha1 ( $ token ) == $ user -> email_verification_token && $ this -> hasOpenEmailValidation ( $ user ) ) { $ newEmail = $ user -> setting -> get ( User :: USER_SETTING_NEWUSEREMAIL ) ; $ user -> email = $ newEmail ; if ( $ user -> update ( true , [ 'email' ] ) ) { $ user -> resetEmailVerification ( ) ; $ newEmail = $ user -> setting -> remove ( User :: USER_SETTING_NEWUSEREMAIL ) ; return [ 'success' => true ] ; } else { return $ this -> sendModelError ( $ user ) ; } } return $ this -> sendArrayError ( [ 'email' => Module :: t ( 'account_changeemail_wrongtokenorempty' ) ] ) ; }
Action to change the email based on token input.

@return boolean
@since 1.2.0
Action to change the email based on token input .