"message": "Method Illuminate\\Auth\\RequestGuard::fromUser does not exist.", "status_code": 500?
"message": "Method Illuminate\\Auth\\RequestGuard::fromUser does not exist.",
"status_code": 500
配置代码
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
];
出现问题的代码
\Auth::guard('api')->fromUser($user)
关于 LearnKu
多提供一点信息,代码,完整的报错,贴一下你 config/auth.php 的代码。你也可以对比一下项目的源码
@liyu001989
首先非常感谢您能回答我的问题
配置文件如下 已经检查过了 和源码文件是一样的
是在调用 \Auth::guard('api')->fromUser($user) 出现的问题 上面已经补充了配置 和 错误问题
@liyu001989
我这个使用的是 Passport 认证
如果修改成 jwt 是否就没法使用 Passport 认证了?
修改成 jwt 之后 postman 报错 Syntax error
我用的 laravel 5.6 版本 在调用 \Auth::guard('api')->fromUser($user) 出现的问题 提示的是应该未找到 fromUser 方法
@liyu001989 您好 再咨询您 一个问题 生成 token 后 如果token 泄露 如果再拿到接口 地址 就会出现 数据泄露 请问 这个种情况 一般如何解决? 例如通常的vue 单页应用 只要拿到 用户token 就可以 免登陆操作 这样会不会很危险?
任何一种 token 泄露了情况都一样,你的问题就是我的银行卡密码泄露了,如果在拿到我的银行卡,那么怎么办。