frontend\controllers\IController::actionPassword PHP 메소드

actionPassword() 공개 메소드

public actionPassword ( $step = '1' )
    public function actionPassword($step = '1')
    {
        $params = ['step' => $step];
        if ($step === '1') {
            $verifyPasswordForm = new VerifyPasswordForm();
            if ($verifyPasswordForm->load(Yii::$app->request->post()) && $verifyPasswordForm->validate()) {
                Yii::$app->session['passwordVerified'] = true;
                return $this->redirect(['password', 'step' => '2']);
            }
            $params['verifyPasswordForm'] = $verifyPasswordForm;
        } elseif ($step === '2' && Yii::$app->session->has('passwordVerified') && Yii::$app->session['passwordVerified']) {
            $changePasswordForm = new ChangePasswordForm();
            $changePasswordForm->load(Yii::$app->request->post());
            if (Yii::$app->request->isAjax) {
                Yii::$app->response->format = Response::FORMAT_JSON;
                return ActiveForm::validate($changePasswordForm);
            }
            if (Yii::$app->request->isPost && $changePasswordForm->change()) {
                Yii::$app->session->setFlash('success', '密码更改成功!');
                return $this->redirect(['password']);
            }
            $params['changePasswordForm'] = $changePasswordForm;
        } else {
            return $this->redirect(['password']);
        }
        return $this->render('password', $params);
    }