现在我正在使用类似的东西来验证我的基本站点上的用户:
Now I'm using something like that for authenticating the user on my base site:
if (Auth::attempt($request->only(['id', 'password']))) {
//
}
如何修改此代码以使用自定义列作为用户名?https://laravel.com/docs/5.3/passport#password-grant-tokens
How can I modify this code for using custom column as username? https://laravel.com/docs/5.3/passport#password-grant-tokens
您可以在用户模型中使用 findForPassport 方法.
You can use findForPassport method in your user model.
该方法以用户名为参数,返回用户模型
This method take username as argument, and return user model
例如:
class User extends Authenticatable
{
use HasApiTokens, Notifiable;
// ... some code
public function findForPassport($username) {
return $this->where('id', $username)->first();
}
}
这篇关于如何使用带有自定义用户名列的 Laravel Passport的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
PHP、MySQL PDOException 的死锁异常代码?Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死锁异常代码?)
PHP PDO MySQL 可滚动游标不起作用PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滚动游标不起作用)
PHP PDO ODBC 连接PHP PDO ODBC connection(PHP PDO ODBC 连接)
使用 PDO::FETCH_CLASS 和魔术方法Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔术方法)
php pdo 只从 mysql 获取一个值;等于变量的值php pdo get only one value from mysql; value that equals to variable(php pdo 只从 mysql 获取一个值;等于变量的值)
MSSQL PDO 找不到驱动程序MSSQL PDO could not find driver(MSSQL PDO 找不到驱动程序)