当前位置: 首页>>代码示例>>PHP>>正文


PHP LoginForm::validate方法代码示例

本文整理汇总了PHP中app\models\LoginForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP LoginForm::validate方法的具体用法?PHP LoginForm::validate怎么用?PHP LoginForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\LoginForm的用法示例。


在下文中一共展示了LoginForm::validate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionLogin

 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;
     }
 }
开发者ID:hoangngk,项目名称:angularbasic,代码行数:10,代码来源:UserController.php

示例2: actionLogin

 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;
     }
 }
开发者ID:aekkapun,项目名称:YiiAngulario,代码行数:13,代码来源:UserController.php

示例3: actionAccess

 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;
 }
开发者ID:Nosthertus,项目名称:SM,代码行数:14,代码来源:UserController.php

示例4: actionIndex

 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]);
 }
开发者ID:s-savchenko,项目名称:aist,代码行数:14,代码来源:LoginController.php

示例5: testRules

 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());
 }
开发者ID:highestgoodlikewater,项目名称:yii2-englishwordbook-demo,代码行数:15,代码来源:LoginFormTest.php

示例6: actionLogin

 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();
         }
     }
 }
开发者ID:xiaojianxin,项目名称:Ontee,代码行数:15,代码来源:SiteController.php

示例7: actionCheckin

 /**
  * 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]);
 }
开发者ID:Fabio-CS,项目名称:quadro,代码行数:35,代码来源:EstadosEmocionaisController.php

示例8: actionLocal

 /**
  * 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]);
 }
开发者ID:Fabio-CS,项目名称:quadro,代码行数:13,代码来源:UsuariosController.php


注:本文中的app\models\LoginForm::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。