How to use Laravel Passport with a custom username column

后端 未结 2 486
我寻月下人不归
我寻月下人不归 2020-12-05 06:37

Now I\'m using something like that for authenticating the user on my base site:

if (Auth::attempt($request->only([\'id\', \'password\']))) {
            /         


        
2条回答
  •  忘掉有多难
    2020-12-05 07:17

    A bit too late to answer, but I've been having a hard time trying to figure this out, so for the sake of completeness and to maybe help others in the future.

    If you take a look to this part of passport's code you'll see that it also looks for a validateForPassportPasswordGrant method, so in addition to Alexander's answer, that's how you can authenticate an user using custom fields.

    Hope it helps someone.

提交回复
热议问题