Ejemplo n.º 1
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]);
 }
Ejemplo n.º 2
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]);
 }
Ejemplo n.º 3
0
 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();
     });
 }
Ejemplo n.º 4
0
 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();
     });
 }
Ejemplo n.º 5
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]);
     }
 }
Ejemplo n.º 6
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]);
     }
 }
Ejemplo n.º 7
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]);
     }
 }
Ejemplo n.º 8
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]);
     }
 }
Ejemplo n.º 9
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'));
 }
Ejemplo n.º 10
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]);
     }
 }
Ejemplo n.º 11
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]);
     }
 }
Ejemplo n.º 12
0
 public function actionLogin()
 {
     $model = \Yii::createObject(LoginForm::className());
     $this->performAjaxValidation($model);
     //        $user_remote= new UserRemote();
     //        $params=\Yii::$app->getRequest()->post();
     //        var_dump($params);die;
     //        if (isset($params['login-form'])){
     //            var_dump($params['login-form']['login'],$params['login-form']['password']);die;
     //        $ruser=$user_remote->getRemoteUser($params['login-form']['login'],$params['login-form']['password']);
     //        }
     if ($model->load(\Yii::$app->getRequest()->post()) && $model->login()) {
         return $this->goBack();
     }
     return $this->render('login', ['model' => $model, 'module' => $this->module]);
 }
 /**
  * Displays the login page.
  *
  * @return string|Response
  */
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         $this->goHome();
     }
     /** @var LoginForm $model */
     $model = Yii::createObject(LoginForm::className());
     $this->performAjaxValidation($model);
     if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) {
         $profile = Profile::findOne(Yii::$app->user->id);
         if (empty($profile->name) || empty($profile->location)) {
             return $this->redirect(['settings/profile?complete=1']);
         } else {
             return $this->goBack();
         }
     }
     return $this->render('login', ['model' => $model, 'module' => $this->module]);
 }
 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]);
 }