#2 - authentication via google #16

Merged
Baakoma merged 10 commits from #2-auth-via-google into main 2022-01-13 14:19:11 +01:00
3 changed files with 6 additions and 6 deletions
Showing only changes of commit 2cdd7ef907 - Show all commits

View File

@@ -26,10 +26,6 @@ class GoogleController extends Controller
$user = User::query()
->where("email", $socialUser->getEmail())
->firstOrFail();
$auth->guard()->login($user, true);
return redirect()->route("dashboard");
} catch (ModelNotFoundException) {
krzysztofrewak commented 2022-01-13 13:38:29 +01:00 (Migrated from github.com)
Review

Is this try-catch really refers to entire block of code? And maybe this failed redirect could be move to the exception?

Is this try-catch really refers to entire block of code? And maybe this failed redirect could be move to the exception?
Baakoma commented 2022-01-13 14:01:50 +01:00 (Migrated from github.com)
Review

I would like to keep it simple for now. I'll refactor it when error handling and notifications/alerts will work.

I would like to keep it simple for now. I'll refactor it when error handling and notifications/alerts will work.
return redirect()
->route("login")
@@ -37,5 +33,9 @@ class GoogleController extends Controller
"oauth" => __("User does not exist."),
]);
}
$auth->guard()->login($user, true);
return redirect()->route("dashboard");
}
}

View File

@@ -12,7 +12,7 @@ class LogoutController extends Controller
{
public function __invoke(Request $request): RedirectResponse
{
$request->user()?->logout();
Auth::logout();
krzysztofrewak commented 2022-01-13 13:40:44 +01:00 (Migrated from github.com)
Review
        $request->user()?->logout();
```suggestion $request->user()?->logout(); ```
Baakoma commented 2022-01-13 13:55:27 +01:00 (Migrated from github.com)
Review

It doesn't work.

It doesn't work.
$request->session()->invalidate();
$request->session()->regenerateToken();

View File

@@ -8,7 +8,7 @@ use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
protected function redirectTo($request): ?string
protected function redirectTo($request): string
{
return route("login");
}