[请益] Laravel5.3 Auth::check() 问题

楼主: DOPIPI (豆腐熊)   2016-11-01 10:31:17
各位先进好
小弟目前手上有个专案需使用“现成不可变动”(oracle)的资料表做登入
priKey 的字段是char(6)
内容会储存 5 或是 6 码的数字不重复
例如 "12345 "(char 未满六码会自动补空格)、"654321"
在Model中已经设好
protected $table = 'logintable';
public $incrementing = false;
protected $primaryKey = 'acct';
自行撰写的LoginController 大致如下
$acct = sprintf('%-6s', $request->input('acct'));
$pwd = $request->input('pwd');
$user = \App\Logintable::find($acct);
if(empty($user) || $user->pwd != $pwd ){
//登入失败
throw new Exception(....);
}
//验证成功登入,且不使用remember_token
Auth::login($user, false);
//转到有受 middleware: auth 保护的页面
return redirect('/home');
===================================================================
问题来了
当使用 "654321" 登入的时候,可以很正常的连到 /home
但使用 "12345 " 登入的时候,在return redirect('/')前使用 dd(Auth::user());
确认都能正确取得实例
可是一跳转页面之后就会自动被laravel视为未登入跳回 login画面
登入成功时的 session 在redirect后被删除掉了
请问除了不使用Auth 自行撰写登入功能外
有其他的方法能使Auth正常运作的吗?
作者: liaosankai (低温烘焙)   2016-11-03 11:49:00
你的 "12345 " 我觉得应该被 trim 过了所以 "12345" 不会等于 "12345 "

Links booklink

Contact Us: admin [ a t ] ucptt.com