本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
示例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]);
}
示例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());
}
示例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();
}
}
}
示例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]);
}
示例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]);
}