Exemplo n.º 1
0
 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         $userdetails = \Yii::$app->user->identity;
         $user = Userform::findOne(['id' => $userdetails->id]);
         $url = \Yii::$app->urlManager->createUrl('user/home');
         return $this->redirect($url, ['model' => $model]);
         //return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 /**
  * Finds user by username
  *
  * @param string $username
  * @return static|null
  */
 public static function findByUsername($username)
 {
     return Userform::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
 }
Exemplo n.º 3
0
 public function actionHome()
 {
     $model = Userform::findOne(['id' => \Yii::$app->user->identity->id]);
     return $this->render('home', ['model' => $model]);
 }