Closed sekar-dev14 closed 2 years ago
LoginController $params = [ 'email' => request('email'), 'password' => request('password') ]; if(Auth::guard('client')->attempt($params)){ $user= Auth::guard('client')->user(); $success['token'] = $user->createToken('MyJarvis')->accessToken; return response()->json( [ 'success'=>$success ], $this->successStatus ); } else { return response()->json( [ 'error' => 'Unauthorized' ], 401 ); } Auth .php `return [ 'defaults' => [ 'guard' => 'client', 'passwords' => 'users', ],
$params = [ 'email' => request('email'), 'password' => request('password') ]; if(Auth::guard('client')->attempt($params)){ $user= Auth::guard('client')->user(); $success['token'] = $user->createToken('MyJarvis')->accessToken; return response()->json( [ 'success'=>$success ], $this->successStatus ); } else { return response()->json( [ 'error' => 'Unauthorized' ], 401 ); }
'guards' => [ 'api' => [ 'driver' => 'passport', 'provider' => 'users', ], 'client' => [ 'driver' => 'passport', 'provider' => 'users', ], ], 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => \App\JarvisRegister::class ] ]
];`
$params = [ 'email' => request('email'), 'password' => request('password') ]; if(Auth::guard('client')->attempt($params)){ $user= Auth::guard('client')->user(); $success['token'] = $user->createToken('MyJarvis')->accessToken; return response()->json( [ 'success'=>$success ], $this->successStatus ); } else { return response()->json( [ 'error' => 'Unauthorized' ], 401 ); }
Auth .php `return [ 'defaults' => [ 'guard' => 'client', 'passwords' => 'users', ],];`