/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load($_POST) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionSignup() { $model = new User(); $model->setScenario('signup'); if ($model->load($_POST) && $model->save()) { if (Yii::$app->getUser()->login($model)) { return $this->goHome(); } } return $this->render('signup', ['model' => $model]); }
public function actionRequestPasswordReset() { $model = new User(); $model->setScenario('requestPasswordResetToken'); // 设置场景为取回密码 if ($model->load(Yii::$app->request->post()) && $model->validate()) { $user = User::findOne(['user_status' => User::STATUS_ACTIVE, 'user_email' => $model->user_email]); if ($user) { $user->generatePasswordResetToken(); if ($user->update(false)) { if ($user->sendRetrieveEmail($user)) { Yii::$app->getSession()->setFlash('requestPasswordResetToken', Yii::t('auth.reset-password', 'Check your email for further instructions.')); // return $this->goHome(); } else { Yii::$app->getSession()->setFlash('requestPasswordResetToken', Yii::t('auth.reset-password', 'Sorry, we are unable to reset password for email provided.')); } } } else { Yii::$app->getSession()->setFlash('requestPasswordResetToken', Yii::t('auth.reset-password', 'User is not ACTIVE, please active user first. ')); } } return $this->render('requestPasswordResetToken', ['model' => $model]); }