diff --git a/src/Account/AuthService.php b/src/Account/AuthService.php index f3a604d..abb583c 100644 --- a/src/Account/AuthService.php +++ b/src/Account/AuthService.php @@ -50,4 +50,6 @@ interface AuthService public function registerAdmin(string $name, string $email): User; public function validateRoles(array $roles): array; + public function isExternal(): bool; + public function redirectHome(): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse; } diff --git a/src/Account/AuthServiceLucent.php b/src/Account/AuthServiceLucent.php index fc17567..80b2f0c 100644 --- a/src/Account/AuthServiceLucent.php +++ b/src/Account/AuthServiceLucent.php @@ -220,4 +220,13 @@ readonly class AuthServiceLucent implements AuthService ->values() ->toArray(); } + + public function isExternal(): bool + { + return false; + } + public function redirectHome(): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse + { + return redirect("/home"); + } } diff --git a/src/Account/AuthServiceLunar.php b/src/Account/AuthServiceLunar.php index f4b7a17..9855eaa 100644 --- a/src/Account/AuthServiceLunar.php +++ b/src/Account/AuthServiceLunar.php @@ -102,4 +102,13 @@ readonly class AuthServiceLunar implements AuthService ->values() ->toArray(); } + + public function isExternal(): bool + { + return true; + } + public function redirectHome(): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse + { + return redirect("/lunar"); + } } diff --git a/src/Http/Controller/AuthController.php b/src/Http/Controller/AuthController.php index 7bc040a..feb2721 100644 --- a/src/Http/Controller/AuthController.php +++ b/src/Http/Controller/AuthController.php @@ -28,6 +28,10 @@ class AuthController public function register(Request $request): View|RedirectResponse { + if ($this->authService->isExternal()) { + return $this->authService->redirectHome(); + } + if ($this->accountService->countUsers() > 0) { return redirect( $this->channelService->channel->lucentUrl . "/login", @@ -43,6 +47,10 @@ class AuthController public function postRegister(Request $request): Response { + if ($this->authService->isExternal()) { + abort(400); + } + if ($this->accountService->countUsers() > 0) { abort(400); } @@ -61,6 +69,9 @@ class AuthController public function login() { + if ($this->authService->isExternal()) { + return $this->authService->redirectHome(); + } if ($this->accountService->countUsers() == 0) { return redirect( $this->channelService->channel->lucentUrl . "/register", @@ -76,6 +87,9 @@ class AuthController public function postLogin(Request $request) { + if ($this->authService->isExternal()) { + abort(400); + } $this->authService->sendLoginEmail($request->input("email")); return []; } @@ -87,6 +101,10 @@ class AuthController // "token" => $request->input("token"), // ]); + if ($this->authService->isExternal()) { + abort(400); + } + return $this->svelte->render( layout: "account", view: "verify", @@ -100,6 +118,10 @@ class AuthController public function postVerify(Request $request) { + if ($this->authService->isExternal()) { + abort(400); + } + try { $this->authService->login( $request->input("email"), @@ -113,6 +135,10 @@ class AuthController public function logout(): RedirectResponse { + if ($this->authService->isExternal()) { + abort(400); + } + $this->session->flush(); return redirect($this->channelService->channel->lucentUrl . "/login"); }