我正在尝试为同一个项目中的移动用户构建一个laravel应用程序和API . 主网站实际上是网站的后端,需要我已经实施的正确身份验证 . 并且api还需要进行身份验证,但具有不同的凭据(不是来自Web的用户模型) .
此时我已在我的项目中添加了dingo api并且工作正常 . 但是现在我还需要为dingo添加jwt . 问题是jwt默认使用App \ User Model,我不想用web用户凭证验证api用户 . 请建议我解决这个问题的最佳方法是什么 . 谢谢
查看文档,看起来您在config.php文件中指定了使用 php artisan vendor:publish 发布的auth提供程序
php artisan vendor:publish
将 auth 设置为您的提供者:https://github.com/tymondesigns/jwt-auth/blob/develop/config/config.php#L252
auth
或者,您可以在 app.php 配置文件中指定要使用的驱动程序和/或用户提供程序:
app.php
https://github.com/laravel/laravel/blob/master/config/auth.php#L69 https://github.com/laravel/laravel/blob/master/config/auth.php#L70
更新:
使迁移到保留客户端表: php artisan make:migration create_clients_table
php artisan make:migration create_clients_table
根据需要更新迁移文件 .
使用 php artisan make:model Client 创建客户端模型
php artisan make:model Client
更新模型以匹配迁移并添加任何关系 .
运行迁移 .
应该这样做this会起作用
您可能需要相应地更新以下内容:
'api' => [ 'driver' => 'token', 'provider' => 'clients', ],
或者可能:
'api' => [ 'driver' => 'token', 'provider' => 'jwt', ],
https://github.com/laravel/laravel/blob/master/config/auth.php#L46
1 回答
查看文档,看起来您在config.php文件中指定了使用
php artisan vendor:publish
发布的auth提供程序将
auth
设置为您的提供者:https://github.com/tymondesigns/jwt-auth/blob/develop/config/config.php#L252或者,您可以在
app.php
配置文件中指定要使用的驱动程序和/或用户提供程序:https://github.com/laravel/laravel/blob/master/config/auth.php#L69 https://github.com/laravel/laravel/blob/master/config/auth.php#L70
更新:
使迁移到保留客户端表:
php artisan make:migration create_clients_table
根据需要更新迁移文件 .
使用
php artisan make:model Client
创建客户端模型更新模型以匹配迁移并添加任何关系 .
运行迁移 .
应该这样做this会起作用
您可能需要相应地更新以下内容:
或者可能:
https://github.com/laravel/laravel/blob/master/config/auth.php#L46