I am using laravel lumen framework v8
and with jwt authentication on the following website
https://jwt-auth.readthedocs.io/en/develop/lumen-installation/
.
Here is some of code snippet that I have used in my project
<?php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'jwt',
'provider' => 'users'
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
]
]
];
cofig/auth.php
I also register this file under the boootstrap/app.php and all the other configuration
This is my controller login function look like
public function login(Request $request)
{
$email = $request->input('email');
$pass = $request->input('password');
$credentials = [
'email'=>$email,
'password'=>md5($pass)
];
dd( Auth::attempt($credentials));
//return response()->json($credentials);
if (! $token = auth('web')->attempt($credentials)) {
return response()->json(['error' => 'Unauthorizedsfwe'], 401);
}
return $this->respondWithToken($token);
}
I am using my existing project DB the password is store in the form of MD5 so I tried this way as well like above but is not working even I also tried to log in with direct hash MD5 but it still not working at all
but when I tried to run this from the response directory on PHPMyAdmin
return response()->json($credentials);
it works but not with the auth('web')->attempt()
method