Exemplo n.º 1
0
 /**
  * Finds the Admin model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Admin the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Admin::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 2
0
 public function actionReset($id, $token = false)
 {
     /** @var Admin $user */
     $user = Admin::findOne($id);
     if ($token !== false && isset($user) && $user->passwordResetToken === $token && $user->passwordResetExpire >= time()) {
         $model = new PasswordResetForm();
         if ($model->load(Yii::$app->getRequest()->post()) && $model->changePassword($user)) {
             Yii::$app->user->login($user);
             return $this->redirect(['index']);
         }
         return $this->render('password-reset', ['model' => $model]);
     }
     throw new NotFoundHttpException();
 }