dsdsm2016 2016-08-30 07:43
浏览 128
已采纳

在Laravel 5.2中进行身份验证时如何使用电话号码而不是电子邮件?

I'm using Laravel 5.2 in a project and need the login form to use phonenumber instead of email for the credentials.

I do not want to edit any Illuminate package files.

  • 写回答

4条回答 默认 最新

  • doutongfu9484 2016-08-30 09:29
    关注

    You can manually authenticate the users:

    public function authenticate(Request $request)
    {
        $password=$request->password;
        $phone=$request->phone_number;
        if (Auth::attempt(['phone_number' => $phone, 'password' => $password]) )
        {     
            return redirect()->intended('/');   
        }
        else 
        {
            return redirect('/login');
        }
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?