Пример #1
0
 public function actionAuth()
 {
     if (!Yii::$app->user->can("admin")) {
         throw new HttpException(403, 'You are not allowed to perform this action.');
     }
     $dataProvider = new ActiveDataProvider(['query' => AuthenticationLog::find()]);
     return $this->render('auth', ['dataProvider' => $dataProvider]);
 }
 /**
  * Display login page
  */
 public function actionLogin()
 {
     /** @var \amnah\yii2\user\models\forms\LoginForm $model */
     // load post data and login
     $model = Yii::$app->getModule("user")->model("LoginForm");
     if ($model->load(Yii::$app->request->post()) && $model->login(Yii::$app->getModule("user")->loginDuration)) {
         $user = \Yii::$app->user->identity;
         $a = new AuthenticationLog();
         $a->user_id = $user->id;
         $a->email = $user->email;
         $a->user_name = $user->username;
         $a->save();
         return $this->goBack(Yii::$app->getModule("user")->loginRedirect);
     }
     // render
     return $this->render('login', ['model' => $model]);
 }