Php Jwt身份验证问题-凭据无效

Php Jwt身份验证问题-凭据无效,php,api,authentication,laravel-5,jwt-auth,Php,Api,Authentication,Laravel 5,Jwt Auth,当我在Laravel中使用auth on created user时,它是有效的,但是。。。当我更改数据库时,我无法再验证它 用户的密码是用bcrypt加密的,当执行哈希::检查()时,返回值为true,但JWT验证总是返回false。 我在使用以下代码时遇到问题: $credentials = $request->only('email', 'senha'); try { if(! $token = JWTAuth::attempt($credentials)){ ret

当我在Laravel中使用auth on created user时,它是有效的,但是。。。当我更改数据库时,我无法再验证它

用户的密码是用bcrypt加密的,当执行哈希::检查()时,返回值为true,但JWT验证总是返回false。

我在使用以下代码时遇到问题:

$credentials = $request->only('email', 'senha');
try {
   if(! $token = JWTAuth::attempt($credentials)){
     return response()->json(['error' => 'invalid_credentials'], 400);
   }
}catch(JWTException $e){
   return response()->json(['error' => 'could_not_create_token'], 500);
}

return response()->json([
  'access_token'  => $token,
  'token_type'    => 'bearer',
  'expires_in'    => auth()->factory()->getTTL() * 60
]);
我查看了一些文章,比如资源页面本身的文章,而其他一些文章就是找不到解决方案

laravel版本是5.2

编辑


数据库中的字段称为“email”和“senha”(pt br语言)。当我更改字段时,错误是相同的

JWTAuth::trument($credentials)
部分将查找输入值“email”和“passowrd”

因此,在凭证中,您必须只传递
$request->only('email','password')
$request->only('email','senha')
JWTAuth::尝试($credentials)
部分将查找输入值“email”和“passowrd”


因此,在凭证中,您必须只传递
$request->only('email','password')
$request->only('email','senha')

我通过使用Laravel标准在银行中创建一个新表来解决问题。

我通过使用Laravel标准在银行中创建一个新表来解决问题。

您可能希望尝试传递密码字段以尝试将其命名为“密码”,即使它没有命名为“密码”,这通常是用户提供商知道哪个字段应该进行哈希检查的方式。您可能希望尝试将密码字段作为名称“password”传递,即使它没有命名为“password”,这通常是用户提供商知道哪个字段应该进行哈希检查的方式。数据库中的字段称为“email”和“senha”(pt br语言)。当我更改字段时,错误是相同的!数据库中的字段称为“email”和“senha”(pt br语言)。当我更改字段时,错误是相同的!