Пример #1
0
 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function actionLogin()
 {
     $this->title = "Авторзация";
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         if (Yii::$app->user->can('salon')) {
             return $this->redirect([Module::URL_ROUTE_PROFILE]);
         } else {
             return $this->redirect(Yii::$app->getUser()->getReturnUrl($this->goHome()));
         }
         //return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Пример #2
0
 public function actionIndex()
 {
     if (!\Yii::$app->user->isGuest) {
         $this->redirect(Url::to(['/home']));
     }
     $model = \Yii::createObject(LoginForm::className());
     $this->performAjaxValidation($model);
     if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) {
         return $this->redirect(Url::to(['/home']));
     }
     return $this->render('index', ['model' => $model, 'module' => $this->module]);
 }