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() { if ($this->accountService->countUsers() == 0) { return redirect($this->channelService->channel->lucentUrl . "/register"); } return view("lucent::auth.login"); } public function postLogin(Request $request) { $this->authService->sendLoginEmail($request->input("email")); return view("lucent::auth.login-success"); } public function verify(Request $request): View { return view("lucent::auth.verify", [ "email" => $request->input("email"), "token" => $request->input("token"), ]); } public function postVerify(Request $request) { try { $this->authService->login($request->input("email"), $request->input("token")); } catch (LucentException $th) { return ResponseFormError::fromException($th); } return []; } public function logout(): RedirectResponse { $this->session->flush(); return redirect($this->channelService->channel->lucentUrl . "/login"); } }