Example #1
0
 /**
  * @return string|\yii\web\Response
  */
 public function actionLogin()
 {
     $model = new LoginForm();
     if ($model->load(\Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     }
     return $this->render('login', ['model' => $model]);
 }
Example #2
0
 public function actionIndex()
 {
     $model = new LoginForm();
     if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) {
         return $this->goBack();
     }
     return $this->render('index', ['model' => $model, 'module' => $this->module]);
 }
Example #3
0
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Example #4
0
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $loginForm = new LoginForm();
     if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) {
         return $this->goBack();
     } else {
         $method = Yii::$app->getRequest()->isAjax ? 'renderAjax' : 'render';
         return $this->{$method}('login', ['loginForm' => $loginForm]);
     }
 }
Example #5
0
 /**
  * Action for loggin in users
  * @param null $returnUrl
  * @return string|Response
  */
 public function actionLogin($returnUrl = null)
 {
     TagDependency::invalidate(Yii::$app->cache, ['Session:' . Yii::$app->session->id]);
     if (\Yii::$app->user->isGuest === false) {
         $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack($returnUrl);
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Example #6
0
 public function actionRegistration()
 {
     $this->layout = '@app/views/layouts/registration';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         ActionHelper::redirecToHome();
         return $this->goBack();
     } else {
         return $this->render('registration', ['model' => $model]);
     }
 }
Example #7
0
 /**
  * Renders login form.
  * @param string $view
  * @param bool $partial
  * @return string view.
  */
 public function actionLogin($view = 'login', $partial = false)
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->redirect($this->getLoginRedirect());
     }
     if (\Yii::$app->request->isAjax || $partial) {
         return $this->renderAjax($view, compact('model'));
     }
     return $this->render($view, compact('model'));
 }
 public function actionLogin()
 {
     $model = new LoginForm();
     $model->load($_POST);
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     if (Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     } elseif ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
 public function actionLogin()
 {
     $this->layout = '@app/views/layouts/login';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         if (Yii::$app->user->identity->role == 2) {
             $session = Yii::$app->session;
             return $this->redirect(['/main/products']);
         } else {
             return $this->goBack();
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }