accountService->countUsers() > 0) { return redirect($this->channelService->channel->lucentUrl . "/login"); } return $this->svelte->render( layout: "account", view: "register", title: "Create an account", ); } public function postRegister(Request $request): Response { if ($this->accountService->countUsers() > 0) { abort(400); } try { $this->authService->registerAdmin( name: $request->input("name"), email: $request->input("email"), ); } catch (LucentException $th) { return fail($th); } return ok(); } public function login(): View|RedirectResponse { if ($this->accountService->countUsers() == 0) { return redirect($this->channelService->channel->lucentUrl . "/register"); } return $this->svelte->render( layout: "account", view: "login", title: "Log in" ); } public function postLogin(Request $request): Response { try { $this->authService->sendLoginEmail($request->input("email")); } catch (LucentException $th) { return fail($th); } return ok(); } public function verify(Request $request): View { return $this->svelte->render( layout: "account", view: "verify", title: "Verify and enter", data: [ "email" => $request->input("email"), "token" => $request->input("token"), ] ); } public function postVerify(Request $request): Response { try { $this->authService->login($request->input("email"), $request->input("token")); } catch (LucentException $th) { return fail($th); } return ok(); } public function logout(): RedirectResponse { $this->session->flush(); return redirect($this->channelService->channel->lucentUrl . "/login"); } }