php - laravel5 ,\Auth::check(),return true,but attempt() return false -
after login,i want add logic before controller,so wrote in middleware . but,i found when
dd(\auth::check()); // returns true;
but
$eid = \auth::user()->eid; //can print value $password = \auth::user()->password; //can print value, dd(\auth::validate(['eid'=>$eid,'password'=>$password])); //it returns false
the whole code:
public function handle($request, closure $next) { dd(\auth::check()); $eid = \auth::user()->eid; $password = \auth::user()->password; dd(\auth::validate(['eid'=>$eid,'password'=>$password])); if ($this->auth->guest()) { // not login if ($request->ajax()) { return response('unauthorized.', 401); } else { return redirect()->guest('auth/login'); } } return $next($request); }
auth::user()->password
password hash , cannot used in validate()
function. can use actual plaintext password in auth::validate()
Comments
Post a Comment