有多个电子邮件时如何登录

How to get log in when having multiple email

电子邮件 ID 相同但密码不同

abc@xyz.com => 123456
abc@xyz.com =>  987654

我想在匹配电子邮件和密码后登录

if (Auth::attempt($credentials, true)) {
    //Check first email and password if it does match return true else false
}

这怎么可能实现,如果可能的话,请指导和详细说明,在此先感谢

您可以首先检索具有给定电子邮件的所有用户。

$users = User::where('email', $request->get('email'))->get();

$users->each(function (User $user) {
    if (\Hash::check($request->get('password'), $user->password)) {
        Auth::login($user);
    }
});

然后您遍历所有用户并自行检查密码。