laravel 5.4是否可以在不登录他的情况下对用户进行身份验证?从laravel doc我能找到的最接近的东西是:Laravel - 无需登录即可验证用户身份
Auth::once($credentials)
但是,这仍然记录用户在这一个请求的duriation。我需要的只是知道用户是否存在该电子邮件和密码。
laravel 5.4是否可以在不登录他的情况下对用户进行身份验证?从laravel doc我能找到的最接近的东西是:Laravel - 无需登录即可验证用户身份
Auth::once($credentials)
但是,这仍然记录用户在这一个请求的duriation。我需要的只是知道用户是否存在该电子邮件和密码。
可以使用Auth::attempt
功能与第三个参数为false
这是登录
$email=$request->email;
$password=$request->password;
if(Auth::attempt(['email'=>$email, 'password'=>$password],false,false))
{
echo "found":
}else {
echo "not found";
}
入住这https://laravel.com/api/5.1/Illuminate/Auth/Guard.html#method_attempt
或者使用Auth::validate
https://laravel.com/api/5.1/Illuminate/Auth/Guard.html#method_validate
如果你需要的是检查是否有用户给出的凭证存在像这样做:
//get the user by email
$user = User::where('email',$email)->first();
if($user !== null){
// if user is found, check if password match against given text
$isRightPassword = Hash::verify($password,$user->password);
}
上面的代码不会验证用户。