auth fiux
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user