本文整理汇总了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');
}
}
示例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]);
}
示例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";
}
}
示例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]);
}
示例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);
}
示例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]);
}
}
示例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]);
}
}
示例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);
}
}
示例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;
}
}
示例10: loginAction
public function loginAction()
{
$request = new LoginRequest(PostRequest::post(), true);
return User::login($request);
}
示例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();
}
}