/** * @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]); }
public function testLoginNoUser() { $model = new LoginForm(['username' => 'not_existing_username', 'password' => 'not_existing_password']); $this->specify('user should not be able to login, when there is no identity', function () use($model) { expect('model should not login user', $model->login())->false(); expect('user should not be logged in', Yii::$app->user->isGuest)->true(); }); }
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]); }
public function testLoginCorrect() { $model = new LoginForm(['username' => 'demo', 'password' => 'demo']); $this->specify('user should be able to login with correct credentials', function () use($model) { expect('model should login user', $model->login())->true(); expect('error message should not be set', $model->errors)->hasntKey('password'); expect('user should be logged in', Yii::$app->user->isGuest)->false(); }); }
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]); } }
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]); } }
/** * 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]); } }
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]); } }
/** * 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() { $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]); } }
public function actionLogin() { $this->view->title = 'Вход'; $this->view->params['breadcrumbs'][] = $this->view->title; $view = 'login'; $model = new LoginForm(); if (Yii::$app->request->getIsPost('LoginForm')) { $model->attributes = Yii::$app->request->post('LoginForm'); if ($model->login() === true) { $this->goBack(); } } return $this->render($view, ['model' => $model]); }