laravel护照自定义密码栏 [英] laravel passport custom password column

查看:77
本文介绍了laravel护照自定义密码栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Laravel的Passport软件包来验证其他密码列.

How can I use Laravel's Passport package to authenticate a different password column.

如果我想从其他用户名"列进行身份验证,则可以使用以下代码完成:

If i want to authenticate from a different 'username' column, it can be done with the following code:

    public function findForPassport($username) {
        return $this->where('id', $username)->first();
    }

它将以Id作为列.如果我想使用其他密码"列怎么办.表中具有不同名称的列,例如'uid_token'.

It will take Id, as the column. What if I want to use a different 'password' column. A column in the table with a different name such as 'uid_token'.

推荐答案

Passport/Bridge要求一种称为validateForPassportPasswordGrant($ password)的方法,您可以在用户模型中覆盖该方法,如果不覆盖此方法,它将在用户表中查找密码"列.我不完全确定为什么他们没有将其配置为使用Authenticatable方法getAuthPassword ...

There's a method the Passport/Bridge asks for called validateForPassportPasswordGrant($password) that you can override in your user model, if you don't override this it will look for a 'password' column in your user table. I'm not entirely sure why they haven't configured it to use Authenticatable method getAuthPassword...

这篇关于laravel护照自定义密码栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆