本文整理汇总了PHP中app\models\LoginForm类的典型用法代码示例。如果您正苦于以下问题:PHP LoginForm类的具体用法?PHP LoginForm怎么用?PHP LoginForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LoginForm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: actionLogin
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$this->layout = 'login';
$model = new LoginForm();
$passResetModel = new PasswordResetRequestForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
if ($passResetModel->load(Yii::$app->request->post()) && $passResetModel->validate()) {
/*Yii::$app->mailer->compose()
->setFrom('[email protected]')
->setTo('[email protected]')
->setSubject('Email sent from Yii2-Swiftmailer')
->setTextBody('asdfasdasd')
->send();*/
if ($passResetModel->sendEmail()) {
Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.');
return $this->goHome();
} else {
Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
return $this->goBack();
}
} else {
return $this->render('login', ['model' => $model, 'passResetModel' => $passResetModel]);
}
}
}
开发者ID:soodsse,项目名称:YII2demo,代码行数:30,代码来源:SiteController.php
示例2: actionIndex
public function actionIndex()
{
$session = Yii::$app->session;
// count login failed
$countLogin = 0;
$session->remove('countLogin');
if ($session->has('countLogin')) {
$countLogin = $session->get('countLogin');
}
$this->layout = 'loginLayout';
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post())) {
if ($model->login()) {
$session->remove('countLogin');
return $this->redirect('/admin/top');
} else {
$countLogin++;
$session->set('countLogin', $countLogin);
}
}
// var_dump($countLogin);
return $this->render('index', ['model' => $model]);
}
开发者ID:absol3112,项目名称:sonneboutique,代码行数:26,代码来源:LoginController.php
示例3: actionRegister
public function actionRegister()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new RegisterForm();
$request = Yii::$app->request;
$post = $request->post();
if (isset($post)) {
$model->attributes = $request->post('RegisterForm');
if ($model->validate()) {
//create user in DB
$user = new User();
$user->username = $model->username;
$user->password = $model->password;
$user->no_login = 0;
$user->save();
//perform login
$login = new LoginForm();
$login->username = $user->username;
$login->password = $user->password;
$login->login();
return $this->goHome();
}
}
return $this->render('register', ['model' => $model]);
}
开发者ID:ren06,项目名称:calculator,代码行数:27,代码来源:SiteController.php
示例4: actionLogin
public function actionLogin()
{
$endDate = \app\models\Weeks::END_DATE;
if (date('Y-m-d') > $endDate) {
return $this->render('unavailable', ['endDate' => $endDate]);
}
if (!\Yii::$app->user->isGuest) {
return $this->AddEssay();
}
if (Yii::$app->request->isAjax && Yii::$app->request->get('sendCodePhone')) {
return $this->sendCodePhone(Yii::$app->request->get('sendCodePhone'));
} elseif (Yii::$app->request->isAjax && Yii::$app->request->get('checkCode') && Yii::$app->request->get('phone')) {
return $this->checkCode(Yii::$app->request->get('phone'), Yii::$app->request->get('checkCode'));
}
$signupForm = new SignupForm();
if ($signupForm->load(Yii::$app->request->post()) && $signupForm->signup()) {
return $this->AddEssay('register');
}
$loginForm = new LoginForm();
if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) {
if (Yii::$app->user->identity->isModerator() || Yii::$app->user->identity->isClient()) {
return $this->redirect(["/admin/index"]);
} else {
return $this->AddEssay('login');
}
}
return $this->render('login', ['loginForm' => $loginForm, 'signupForm' => $signupForm]);
}
开发者ID:samboleika,项目名称:shell,代码行数:28,代码来源:SiteController.php
示例5: actionLogin
public function actionLogin()
{
$nombre = null;
if (!\Yii::$app->user->isGuest) {
$nombre = $nombre = Yii::$app->user->identity->nombre_usuario;
if (User::isUserAdmin(Yii::$app->user->identity->id)) {
$this->redirect(['usuario/admin']);
}
if (User::isUserProfe(Yii::$app->user->identity->id)) {
$this->redirect(['usuario/profesor']);
}
if (User::isUserSubcomision(Yii::$app->user->identity->id)) {
$this->redirect(['usuario/subcomision']);
}
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$nombre = Yii::$app->user->identity->nombre_usuario;
if (User::isUserAdmin(Yii::$app->user->identity->id)) {
$this->redirect(['usuario/admin']);
}
if (User::isUserProfe(Yii::$app->user->identity->id)) {
$this->redirect(['usuario/profesor']);
}
if (User::isUserSubcomision(Yii::$app->user->identity->id)) {
$this->redirect(['usuario/subcomision']);
}
}
return $this->render('login', ['model' => $model]);
}
开发者ID:emiherber,项目名称:sgdcae,代码行数:30,代码来源:UsuarioController.php
示例6: actionIndex
/**
* Вывод главной страницы с 3 формами:
* авторизация, регистрация и восстановление
* пароля. Все 3 обработчика форм
* лаконичнее располагать по одному
* запросу
*
* @return string|\yii\web\Response
*/
public function actionIndex()
{
if (Yii::$app->user->isGuest) {
//Авторизация
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
//Регистрация
$reg = new RegForm();
if ($reg->load(Yii::$app->request->post()) && $reg->save()) {
Yii::$app->getSession()->setFlash('reg-success');
return $this->goBack();
}
//Восстановление пароля
$forget = new PasswordResetForm();
if ($forget->load(Yii::$app->request->post()) && $forget->validate()) {
if ($forget->sendEmail()) {
Yii::$app->getSession()->setFlash('forget-send');
}
return $this->goBack();
}
return $this->render('index', ['model' => $model, 'reg' => $reg, 'forget' => $forget]);
} else {
return $this->render('panel');
}
}
开发者ID:Shekhovtsovy,项目名称:yii2-start-auth-app,代码行数:36,代码来源:SiteController.php
示例7: actionLogin
public function actionLogin()
{
$this->layout = 'login';
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$role = Yii::$app->user->identity->getRole(Yii::$app->user->id);
if ($role == "instructor") {
$url = Yii::$app->urlManager->createUrl("instructor/instructor");
$this->redirect($url);
} else {
if ($role == "admin") {
$url = Yii::$app->urlManager->createUrl("site/dashboard");
$this->redirect($url);
} else {
if ($role == "student") {
$url = Yii::$app->urlManager->createUrl("student/student");
$this->redirect($url);
} else {
return $this->goBack();
}
}
}
} else {
return $this->render('login', ['model' => $model]);
}
}
开发者ID:Junaid-Farid,项目名称:olc,代码行数:29,代码来源:SiteController.php
示例8: testLoginCorrect
public function testLoginCorrect()
{
$model = new LoginForm(['username' => 'demo', 'password' => 'demo']);
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();
}
开发者ID:mrarthur,项目名称:webinar-tests,代码行数:7,代码来源:LoginFormTest.php
示例9: actionLogin
public function actionLogin()
{
$serviceName = Yii::$app->getRequest()->getQueryParam('service');
if (isset($serviceName)) {
/** @var $eauth \nodge\eauth\ServiceBase */
$eauth = Yii::$app->get('eauth')->getIdentity($serviceName);
$eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl());
$eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login'));
try {
if ($eauth->authenticate()) {
// var_dump($eauth->getIsAuthenticated(), $eauth->getAttributes()); exit;
$identity = User::findByEAuth($eauth);
Yii::$app->getUser()->login($identity);
// special redirect with closing popup window
$eauth->redirect();
} else {
// close popup window and redirect to cancelUrl
$eauth->cancel();
}
} catch (\nodge\eauth\ErrorException $e) {
// save error to show it later
Yii::$app->getSession()->setFlash('error', 'EAuthException: ' . $e->getMessage());
// close popup window and redirect to cancelUrl
// $eauth->cancel();
$eauth->redirect($eauth->getCancelUrl());
}
}
$model = new LoginForm();
if ($model->load($_POST) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', array('model' => $model));
}
}
开发者ID:kilinanatoly,项目名称:yii2-eauth-demo,代码行数:34,代码来源:SiteController.php
示例10: actionLogin
public function actionLogin()
{
$model = new LoginForm();
if (!Yii::$app->user->isGuest or $model->load(Yii::$app->request->post()) && $model->login()) {
$usuarioActual = UsuariosRoles::find()->where('usuarioId = :id', ['id' => Yii::$app->user->id])->all();
foreach ($usuarioActual as $ua) {
if ($ua->roles->nombre == "educacion") {
return $this->redirect(["site/escuelas"]);
} else {
if ($ua->roles->nombre == "Proyectos") {
return $this->redirect(['proyectos/index']);
} else {
if ($ua->roles->nombre == "eduardo") {
return $this->redirect(['dictamenes/index']);
} else {
if ($ua->roles->nombre == "Zonificacion") {
return $this->redirect(['tramite-zonificacion/index']);
} else {
if ($ua->roles->nombre == "Uso de Suelo") {
return $this->redirect(['tramite-zonificacion/index']);
//$rol = UsuariosRoles::find()->where('usuarioId = '. Yii::$app->user->id)->one();
//$tramites = TipoTramitesRoles::find()->where('roleId = '. $rol->roleId . ' and leer = 1' )->all();
//return $this->redirect(['tipos-tramite/index']);
//'index',['tipos-tramites'=>$tramites]);
} else {
if ($ua->roles->nombre == 'Dev') {
return $this->redirect(['tramite-zonificacion/index']);
} else {
if ($ua->roles->nombre == 'pedro') {
return $this->redirect(['tramites-espectaculares/index']);
} else {
if ($ua->roles->nombre == 'Fraccionamiento') {
return $this->redirect(['tramites-autorizacion/index']);
} else {
if ($ua->roles->nombre == 'Construccion') {
return $this->redirect(['tramites-alineamiento/index']);
} else {
if ($ua->roles->nombre == 'Sistemas') {
return $this->redirect(['tipos-tramite/index']);
} else {
if ($ua->roles->nombre == "Direccion") {
return $this->redirect(['tramite-zonificacion/index']);
}
}
}
}
}
}
}
}
}
}
}
}
} else {
$requisitos = Requisitos::find()->all();
return $this->render('login', ['model' => $model, 'requisitos' => $requisitos]);
}
}
开发者ID:rzamarripa,项目名称:du,代码行数:59,代码来源:SiteController.php
示例11: actionLogin
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
return $this->render('login', compact('model'));
}
开发者ID:tilhom,项目名称:hello-yii2,代码行数:8,代码来源:MainController.php
示例12: actionLogin
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$this->goHome();
}
return $this->render('login', ['model' => $model]);
}
开发者ID:NikitaBarinov,项目名称:Yii2App,代码行数:8,代码来源:MainController.php
示例13: actionLogin
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->redirect(\Yii::$app->urlManager->createUrl('admin/index'));
}
return $this->render('login', ['model' => $model]);
}
开发者ID:peck94,项目名称:linode,代码行数:8,代码来源:SiteController.php
示例14: actionSignin
/**
* User auth method.
* @return array
*/
public function actionSignin()
{
$model = new LoginForm(new User());
if ($model->load(\Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) {
return ['token' => \Yii::$app->user->identity->getAuthKey(), 'success' => true];
} else {
return ['message' => implode(' ', $model->getFirstErrors()), 'success' => false];
}
}
开发者ID:artpro676,项目名称:twitter,代码行数:13,代码来源:AuthController.php
示例15: actionIndex
/**
* Display login form to authorize user
*/
public function actionIndex()
{
$model = new LoginForm();
if ($model->load(\Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('index', ['model' => $model]);
}
}
开发者ID:francisberesford,项目名称:econosim-registry,代码行数:12,代码来源:AuthController.php
示例16: testLoginWrongPassword
public function testLoginWrongPassword()
{
$model = new LoginForm(['username' => 'demo', 'password' => 'wrong_password']);
$this->specify('user should not be able to login with wrong password', function () use($model) {
expect('model should not login user', $model->login())->false();
expect('error message should be set', $model->errors)->hasKey('password');
expect('user should not be logged in', Yii::$app->user->isGuest)->true();
});
}
开发者ID:anmaslov,项目名称:start-page,代码行数:9,代码来源:LoginFormTest.php
示例17: actionLogin
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->redirect(Url::to(['video/index']));
} else {
return $this->render('login', ['model' => $model]);
}
}
开发者ID:abutouq,项目名称:video,代码行数:9,代码来源:SiteController.php
示例18: testLoginCorrect
public function testLoginCorrect()
{
$model = new LoginForm(['username' => 'admin', 'password' => 'adminredis']);
$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();
});
}
开发者ID:insolita,项目名称:yii2-redisman-app,代码行数:9,代码来源:LoginFormTest.php
示例19: 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
示例20: actionLogin
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
//print_r(Yii::$app->request->post());
return $this->render('login', ['model' => $model]);
}
}
开发者ID:sevenzhou1218,项目名称:YiiTest,代码行数:10,代码来源:SiteController.php
注:本文中的app\models\LoginForm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论