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


PHP User::login方法代码示例

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


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

示例1: login_check

 /**
  * Verify if the user is sign-in or not
  * @return void
  */
 public function login_check()
 {
     $islogin = User::login();
     if ($islogin === true) {
         $this->redirectTo('posts/index');
     } else {
         return $this->redirectTo('users/login');
     }
 }
开发者ID:bazizi426,项目名称:SimpleBlog,代码行数:13,代码来源:UsersController.php

示例2: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new User();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     }
     return $this->render('login', ['model' => $model]);
 }
开发者ID:zhoutonglx,项目名称:blog,代码行数:11,代码来源:UserController.php

示例3: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new User();
     if ($model->login()) {
         return $this->goBack();
     } else {
         echo "strannaya oshibka";
     }
 }
开发者ID:anmaslov,项目名称:start-page,代码行数:12,代码来源:SiteController.php

示例4: actionLogin

 /**
  *
  * Please careful if you want to delete or modify methods below.
  *
  */
 public function actionLogin()
 {
     $model = new User();
     $model->scenario('login');
     if (App::$app->request->post()) {
         if ($model->login(App::$app->request->post())) {
             return $this->redirect('admin');
         } else {
             $this->alert = ['danger' => 'Username/Email or Password wrong.'];
         }
     }
     return $this->render('login', ['model' => $model]);
 }
开发者ID:mgilangjanuar,项目名称:slimedoo,代码行数:18,代码来源:SiteController.php

示例5: actionLogin

 public function actionLogin($IVAOTOKEN = null)
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     if (!$IVAOTOKEN) {
         return $this->redirect(Yii::$app->params['api_url']);
     }
     //have the token
     $model = new User();
     $model->login($IVAOTOKEN);
     $this->redirect(Yii::$app->user->returnUrl);
 }
开发者ID:bth2008,项目名称:rferu,代码行数:13,代码来源:SiteController.php

示例6: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new User();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return 'aaaaa';
         return $this->redirect(Url::to(['posts/index']));
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:hysdop,项目名称:YobaCMS,代码行数:13,代码来源:SiteController.php

示例7: actionIndex

 public function actionIndex()
 {
     Yii::$app->controller->layout = false;
     if (!\Yii::$app->user->isGuest) {
         $this->redirect(Url::toRoute('admin/index'));
         //已登录直接跳转
     }
     $model = new User(['scenario' => 'login']);
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->redirect(Url::toRoute('admin/index'));
     } else {
         return $this->render('index', ['model' => $model]);
     }
 }
开发者ID:sxunt520,项目名称:YIIDEV,代码行数:14,代码来源:SiteController.php

示例8: login

 public function login()
 {
     $data = Input::json()->all();
     $rules = ['username' => 'required|max:32|min:4|string', 'passwd' => 'required|max:32|min:4|string'];
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Response::json($validator->messages(), 422);
     }
     $user = User::login($data['username'], md5($data['passwd']));
     if (!empty($user)) {
         return $this->set_cookie_by_user($user);
     } else {
         return Response::json('', 403);
     }
 }
开发者ID:hncg,项目名称:watermelon,代码行数:15,代码来源:AuthController.php

示例9: actionLogin

 /**
  * log the user in B.O
  *
  * @return null|string|\yii\web\Response
  * @throws Exception
  * @throws \Exception
  */
 public function actionLogin()
 {
     try {
         Yii::trace('Trace : ' . __METHOD__, __METHOD__);
         $response = null;
         $model = new User(['scenario' => 'login']);
         if ($model->load(Yii::$app->request->post()) && $model->login()) {
             $response = $this->redirect(['/admin/index']);
         }
         if ($response === null) {
             $response = $this->render('login', ['model' => $model]);
         }
         return $response;
     } catch (Exception $e) {
         Yii::error($e->getMessage(), __METHOD__);
         throw $e;
     }
 }
开发者ID:artoodetoo,项目名称:BlogMVC,代码行数:25,代码来源:AdminController.php

示例10: loginAction

 public function loginAction()
 {
     $request = new LoginRequest(PostRequest::post(), true);
     return User::login($request);
 }
开发者ID:ynijar,项目名称:testtask,代码行数:5,代码来源:UserController.php

示例11: User

<?php

//namespace app\core;
use app\models\Cookie;
use app\models\Config;
use app\models\Session;
use app\models\User;
use app\classes\DB;
session_start();
$GLOBALS['config'] = ['mysql' => ['host' => '127.0.0.1', 'username' => 'root', 'password' => 'root', 'db' => 'test'], 'remember' => ['cookie_name' => 'hash', 'cookie_expiry' => 604800], 'session' => ['session_name' => 'root', 'token_name' => 'token']];
spl_autoload_register(function ($class) {
    require_once 'classes/' . $class . '.php';
});
require_once "functions/sanitize.php";
if (Cookie::exists(Config::get('remember/cookie_name')) && !Session::exists(Config::get('session/session_name'))) {
    $hash = Cookie::get(Config::get('remember/cookie_name'));
    $hashCheck = DB::connect()->get('users_session', ['hash', '=', $hash]);
    if ($hashCheck->count()) {
        $user = new User($hashCheck->first()->user_id);
        $user->login();
    }
}
开发者ID:sydorenkovd,项目名称:test-items,代码行数:22,代码来源:init.php


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