Open nikolaynesov opened 6 years ago
Well you still need to create a user in the system right? How will you know which to link to on a login next time.
On Dec 15, 2017 15:44, "Nikolay" notifications@github.com wrote:
https://github.com/websanova/laravel-api-demo/blob/ b7ff0ddff48bb71e68a8bba820f36140504fd15a/app/Http/Controllers/Api/v1/ AuthController.php#L173
Hey @websanova https://github.com/websanova,
Why do we return this at all if oauth2 function already generates the url and makes the redirect without even touching the backend? Can we just check if the the code exists, parse the socialite user etc. For ex.:
if (!$request->has('code')) {
return response(['ErrorParsingAuthCode' => 'No callback code found'], 400); } $user = $this->userService->findOrCreate( $this->socialite->driver($provider)->stateless()->user() ); if (!empty($user)) { if (!$token = JWTAuth::fromUser($user)) { throw new AuthorizationException; } return response([ 'msg' => 'Successfully logged in via ' . $provider . '.' ])->header('Authorization', $token); } return response(['ErrorGettingSocialUser' => 'There was an error getting the ' . $provider . ' user.'], 400);
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/websanova/laravel-api-demo/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy1jp57Gj0rey-S1rU_l29XvSWafyks5tAtpDgaJpZM4RD-th .
https://github.com/websanova/laravel-api-demo/blob/b7ff0ddff48bb71e68a8bba820f36140504fd15a/app/Http/Controllers/Api/v1/AuthController.php#L173
Hey @websanova,
Why do we return this at all if
oauth2
function already generates the url and makes the redirect without even touching the backend? Can we just check if the the code exists, parse the socialite user etc. For ex.: