Esempio n. 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]);
 }
Esempio n. 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]);
 }
Esempio n. 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]);
     }
 }
Esempio n. 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]);
     }
 }
Esempio n. 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]);
     }
 }
Esempio n. 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]);
     }
 }
Esempio n. 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'));
 }
Esempio n. 8
0
 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]);
     }
 }
Esempio n. 9
0
 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]);
     }
 }