Пример #1
0
 public function actionLogin()
 {
     $model = new LoginForm();
     if (\Yii::$app->request->isAjax) {
         $phone = \Yii::$app->request->post('phone');
         $pass = \Yii::$app->request->post('password');
         $phone = str_replace(['(', ')', '-', '+'], "", $phone);
         $phone = substr($phone, 2);
         $model->phone = $phone;
         $model->password = $pass;
         if ($model->login()) {
             return $this->redirect('/');
         } else {
             return json_encode(['error' => true, 'message' => 'Номер телефона или пароль введены неверно']);
         }
     } else {
         if (\Yii::$app->user->isGuest) {
             if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
                 if ($model->login()) {
                     return $this->redirect('/');
                 }
             }
             return $this->render('login', ['model' => $model]);
         } else {
             return $this->redirect('/');
         }
     }
 }
Пример #2
0
 /**
  * Вход на сайт
  *
  * @return LoginForm | string
  * @throws \yii\base\InvalidConfigException
  */
 public function actionLogin()
 {
     $model = new LoginForm();
     if ($model->load(\Yii::$app->request->post(), '') && $model->login()) {
         return Yii::$app->user->identity->getAuthKey();
     } else {
         return $model;
     }
 }
Пример #3
0
 /**
  * Renders the index view for the module
  * @return string
  */
 public function actionIndex()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->redirect(Yii::$app->user->returnUrl);
     } else {
         return $this->render('index', ['model' => $model]);
     }
 }
Пример #4
0
 public function actionLogin()
 {
     $model = new LoginForm();
     if (Yii::$app->request->isAjax) {
         $model->load($_POST);
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
 public function actionLogin()
 {
     Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-success'], 'body' => Yii::t('frontend', 'Your account has been successfully saved')]);
     $model = new LoginForm();
     if (Yii::$app->request->isAjax) {
         $model->load($_POST);
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Пример #6
0
 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         $this->redirect('/user/sign-in/login', 200);
     }
     $searchModel = new PartnerSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $model = new LoginForm();
     if (Yii::$app->request->isAjax) {
         $model->load($_POST);
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('index', ['model' => $model]);
     }
 }