Login Googgle (Verificar que exista en la lista de confianza)
This commit is contained in:
parent
80637327ee
commit
1d342997ca
@ -31,14 +31,12 @@ public function handleProviderCallback($provider){
|
||||
|
||||
try {
|
||||
$userProvider = Socialite::driver($provider) ->stateless()->user();
|
||||
error_log(json_encode($userProvider->user));
|
||||
}
|
||||
catch (ClientException $exception) {
|
||||
return response()->json(['error' => 'Credenciales de google invalidas.'],422);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset(User::where("email","=", $userProvider->email)->first()){
|
||||
$userCreated = User::firstOrCreate(
|
||||
[
|
||||
'email' => $userProvider->email
|
||||
@ -66,9 +64,16 @@ public function handleProviderCallback($provider){
|
||||
"message" => "Usuario logueado",
|
||||
"user" => $userCreated,
|
||||
"image" => $userProvider->getAvatar(),
|
||||
|
||||
"role" => $userCreated->roles[0]->name,
|
||||
"access_token" => $token
|
||||
]);
|
||||
}
|
||||
else{
|
||||
return response()->json([
|
||||
"status" => 0,
|
||||
"message" => "Usuario no registrado en el sistema",
|
||||
], 404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user