Esempio n. 1
0
 public function actionLogin()
 {
     $model = new LoginForm();
     if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) {
         return ['access_token' => Yii::$app->user->identity->getAuthKey()];
     } else {
         $model->validate();
         return $model;
     }
 }
Esempio n. 2
0
 public function actionLogin()
 {
     if (Yii::$app->getRequest()->getMethod() === 'OPTIONS') {
         return true;
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return User::findOne(['email' => $model->email]);
     } else {
         $model->validate();
         return $model;
     }
 }
Esempio n. 3
0
 public function actionAccess()
 {
     $response = ['success' => false, 'errors' => [], 'data' => []];
     $model = new LoginForm();
     $post = ['LoginForm' => Yii::$app->request->post()];
     $model->load($post);
     if ($model->validate()) {
         $response['data'] = User::find(['username' => $post['LoginForm']['username']])->select(['id', 'username', 'email', 'auth_key'])->one();
         $response['success'] = true;
     } else {
         $response['errors'] = $model->getErrors();
     }
     return $response;
 }
Esempio n. 4
0
 public function actionIndex()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $model->login();
             $this->goBack();
         }
     }
     return $this->render('index', ['model' => $model]);
 }
 public function testRules()
 {
     // empty username and password
     $model = new LoginForm(['username' => '', 'password' => '']);
     $this->assertFalse($model->validate());
     // empty password
     $model = new LoginForm(['username' => $this->users['user1']['username'], 'password' => '']);
     $this->assertFalse($model->validate());
     // empty username
     $model = new LoginForm(['username' => '', 'password' => str_repeat($this->users['user1']['username'], 2)]);
     $this->assertFalse($model->validate());
     // ok
     $model = new LoginForm(['username' => $this->users['user1']['username'], 'password' => str_repeat($this->users['user1']['username'], 2)]);
     $this->assertTrue($model->validate());
 }
Esempio n. 6
0
 public function actionLogin()
 {
     $model = new LoginForm();
     $user = new User();
     $post = Yii::$app->request->post();
     if (empty($post['username'])) {
         return $this->render('error', ["name" => "wrong", "message" => "You are not allowed to access this page"]);
     } else {
         $model->telephone = $post['username'];
         $model->password = $post['password'];
         if ($model->validate()) {
             $model->login();
         }
     }
 }
 /**
  * Lists all EstadosEmocionais models.
  * @return mixed
  */
 public function actionCheckin()
 {
     $model = new EstadosEmocionais();
     if (Yii::$app->request->post()) {
         $model->id_tipo_estado_emocional = Yii::$app->request->get("id_tipo_estado_emocional");
         $model->id_usuario = Yii::$app->user->getId();
         $model->motivo = "";
         $model->data = date('Y-m-d');
         $model->criado_por = Yii::$app->user->getId();
         if ($model->save()) {
             $model->sendEmail();
             Yii::$app->session->setFlash('success', 'Check-in de estado emocional realizado com sucesso!');
             Yii::$app->user->logout();
             $model = new LoginForm();
             $model->scenario = "local";
             $model->matricula = Yii::$app->params['TabletMatricula'];
             $model->password = Yii::$app->params['TabletSenha'];
             if ($model->validate()) {
                 $model->login();
                 return $this->redirect(['usuarios/local', 'msg' => '1']);
             }
         }
         Yii::$app->session->setFlash('error', 'Erro ao realizar o check-in');
         $this->redirect(['usuarios/local']);
     } else {
         if (Yii::$app->user->getIdentity()->getEstadoEmocionalPrincipal()) {
             return $this->render('//site/menu-colaborador');
         }
     }
     return $this->render('checkin', ['model' => $model]);
 }
Esempio n. 8
0
 /**
  * Processo de Login
  */
 public function actionLocal()
 {
     $model = new LoginForm();
     $model->scenario = "local";
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->login();
         return $this->redirect(["estados-emocionais/checkin"]);
     }
     return $this->render('login', ['model' => $model]);
 }