Skip to content

Commit 62d6357

Browse files
committed
refactor: callback processing logic to the authentication service
1 parent fcf8009 commit 62d6357

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

app/Http/Controllers/AuthController.php

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,7 @@ public function callback(Request $request, string $provider): View
117117
$user = $userProvider->user;
118118
}
119119

120-
$message = [
121-
'ok' => true,
122-
'provider' => $provider,
123-
];
124-
125-
// If the guard is web, we will use the default login process
126-
if (config('auth.defaults.guard') === 'web') {
127-
Auth::login($user, true);
128-
$request->session()->regenerate();
129-
} else {
130-
// If the guard is api, we will use the token based authentication
131-
$token = $user->createDeviceToken(
132-
device: $request->deviceName(),
133-
ip: $request->ip(),
134-
remember: $request->input('remember', false)
135-
);
136-
137-
$message['token'] = $token;
138-
}
120+
$message = $this->authService->handleCallback($request, $user);
139121

140122
return view('oauth', [
141123
'message' => $message,

0 commit comments

Comments
 (0)