【发布时间】:2019-09-03 09:23:57
【问题描述】:
令牌被创建为 cookie,我可以在浏览器中看到它,但它没有保存在数据库中。
这是我的用户模型:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
public $timestamps = false;
protected $table = 'accounts';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'Username', 'email', 'Password', 'Nickname', 'SecretQuestion', 'SecretAnswer',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'Password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
我的 LoginController 中的登录方法:
public function login(Request $request)
{
$user = User::where('Username', $request->Username)
->where('Password', md5($request->password))
->first();
if (is_null($user)) return back()->with('error', 'Votre identifiant ou mot de passe est incorrect.');
Auth::login($user, $request->remember == 'on' ? true : false);
if (Auth::check()) return Redirect::to('/');
}
当我检查或不检查 remember_me 选项时,它会相应地使用 Auth::login() 方法,并带有 true 或 false 参数。
但是,在我的数据库中,该字段从未设置过,尽管我可以在浏览器中看到一个令牌remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d。
我的数据库中的字段:
remember_token varchar(100) null,
【问题讨论】:
-
你为什么要
md5输入密码?您使安全登录不安全。 -
我为其开发网站的应用程序使用 md5 身份验证。我别无选择。
标签: php laravel token remember-me