frontend/controllers/UserController.php
/**
     * Display Confirm registration page
     * @return mixed
     */
Display Confirm registration page
@return mixed
Display Confirm registration page @return mixed
public function actionConfirmRegistration()
    {
        if (!Yii::$app->user->isGuest) {
            $testUser = Yii::$app->user->identity;
            if ($testUser->user_status == Users::STATUS_CONFIRMED) {
                Yii::$app->session->setFlash('error', [
                    'message'   => Yii::t('app/flash-messages', 'ConfirmRegistrationAlreadyExist'),
                    'ttl'       => FLASH_MESSAGES_TTL,
                    'showClose' => true,
                    'alert_action' => 'actionConfirmRegistration',
                ]);
                return $this->goHome();
            }
        }
        $model = new DynamicModel(['token']);
        $model->addRule('token', 'required');
        $model->addRule('token', 'string', ['min'=>6, 'max'=>255]);
        if ($model->load(['ConfirmRegistration' => $_GET], 'ConfirmRegistration') && $model->validate()) {
            $user = Users::findByPasswordResetToken($model->token, true);
            if ($user) {
                $user->user_status = Users::STATUS_CONFIRMED;
                $user->removePasswordResetToken();
                if ($user->save()) {
                    Yii::$app->session->setFlash('success', [
                        'message'   => Yii::t('app/flash-messages', 'ConfirmRegistration_success'),
                        'ttl'       => FLASH_MESSAGES_TTL,
                        'showClose' => true,
                        'alert_action' => 'actionConfirmRegistration',
                    ]);
                    MailTemplatesStatic::sendByKey(MailTemplatesStatic::template_key_SetupDevices, $user->user_email, ['UserObject' => $user]);
                    if (Yii::$app->user->isGuest) {
                        UserActionsLog::saveUserActionData($user->user_id);
                        return $this->redirect('/');
                    } else {
                        return $this->redirect(['files']);
                    }
                }
            }
        }
        Yii::$app->session->setFlash('error', [
            'message'   => Yii::t('app/flash-messages', 'ConfirmRegistration_error'),
            'ttl'       => FLASH_MESSAGES_TTL,
            'showClose' => true,
            'alert_action' => 'actionConfirmRegistration',
        ]);
        return $this->goHome();
    }
public function actionConfirmRegistration ( ) { if ( ! Yii :: $ app -> user -> isGuest ) { $ testUser = Yii :: $ app -> user -> identity ; if ( $ testUser -> user_status == Users :: STATUS_CONFIRMED ) { Yii :: $ app -> session -> setFlash ( 'error' , [ 'message' => Yii :: t ( 'app/flash-messages' , 'ConfirmRegistrationAlreadyExist' ) , 'ttl' => FLASH_MESSAGES_TTL , 'showClose' => true , 'alert_action' => 'actionConfirmRegistration' , ] ) ; return $ this -> goHome ( ) ; } } $ model = new DynamicModel ( [ 'token' ] ) ; $ model -> addRule ( 'token' , 'required' ) ; $ model -> addRule ( 'token' , 'string' , [ 'min' => 6 , 'max' => 255 ] ) ; if ( $ model -> load ( [ 'ConfirmRegistration' => $ _GET ] , 'ConfirmRegistration' ) && $ model -> validate ( ) ) { $ user = Users :: findByPasswordResetToken ( $ model -> token , true ) ; if ( $ user ) { $ user -> user_status = Users :: STATUS_CONFIRMED ; $ user -> removePasswordResetToken ( ) ; if ( $ user -> save ( ) ) { Yii :: $ app -> session -> setFlash ( 'success' , [ 'message' => Yii :: t ( 'app/flash-messages' , 'ConfirmRegistration_success' ) , 'ttl' => FLASH_MESSAGES_TTL , 'showClose' => true , 'alert_action' => 'actionConfirmRegistration' , ] ) ; MailTemplatesStatic :: sendByKey ( MailTemplatesStatic :: template_key_SetupDevices , $ user -> user_email , [ 'UserObject' => $ user ] ) ; if ( Yii :: $ app -> user -> isGuest ) { UserActionsLog :: saveUserActionData ( $ user -> user_id ) ; return $ this -> redirect ( '/' ) ; } else { return $ this -> redirect ( [ 'files' ] ) ; } } } } Yii :: $ app -> session -> setFlash ( 'error' , [ 'message' => Yii :: t ( 'app/flash-messages' , 'ConfirmRegistration_error' ) , 'ttl' => FLASH_MESSAGES_TTL , 'showClose' => true , 'alert_action' => 'actionConfirmRegistration' , ] ) ; return $ this -> goHome ( ) ; }
Display Confirm registration page
 @return mixed
Display Confirm registration page @return mixed
/** @var \common\models\Users $testUser */ //var_dump($user); exit;