Jwt-auth: Implementing jwt-auth in laravel/lumen mongodb is hard.

Created on 19 Jan 2021  路  2Comments  路  Source: tymondesigns/jwt-auth

Implementing this library to a MongoDB is hard. Any thought? or any Idea how to make this possible in mongodb.

Most helpful comment

Create custom validation and then use login($user) method instead attempt.

$pass=null;
$result=User::where('username',$credentials['username'])
                    ->first();

if ($result->userpassword==$pass && $result->active==1) {
            $token = Auth::guard('api')->login($result);
            return $this->respondWithToken($token);
        }else{          
            return response()->json([
                                    'page' => 'login',
                                    'error' => $message,                                    
                                ], 401);        
        }     

All 2 comments

Create custom validation and then use login($user) method instead attempt.

$pass=null;
$result=User::where('username',$credentials['username'])
                    ->first();

if ($result->userpassword==$pass && $result->active==1) {
            $token = Auth::guard('api')->login($result);
            return $this->respondWithToken($token);
        }else{          
            return response()->json([
                                    'page' => 'login',
                                    'error' => $message,                                    
                                ], 401);        
        }     

Create custom validation and then use login($user) method instead attempt.

$pass=null;
$result=User::where('username',$credentials['username'])
                    ->first();

if ($result->userpassword==$pass && $result->active==1) {
            $token = Auth::guard('api')->login($result);
            return $this->respondWithToken($token);
        }else{            
            return response()->json([
                                    'page' => 'login',
                                    'error' => $message,                                    
                                ], 401);        
        }     

thanks for the reply and I really appreciate it,,, I was able actually to solve my problem, by following the docu on how to set up and it was very awesome, jwt-auth is the best.,,

Was this page helpful?
0 / 5 - 0 ratings