auth fiux
This commit is contained in:
@@ -50,4 +50,6 @@ interface AuthService
|
|||||||
public function registerAdmin(string $name, string $email): User;
|
public function registerAdmin(string $name, string $email): User;
|
||||||
|
|
||||||
public function validateRoles(array $roles): array;
|
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()
|
->values()
|
||||||
->toArray();
|
->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()
|
->values()
|
||||||
->toArray();
|
->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
|
public function register(Request $request): View|RedirectResponse
|
||||||
{
|
{
|
||||||
|
if ($this->authService->isExternal()) {
|
||||||
|
return $this->authService->redirectHome();
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->accountService->countUsers() > 0) {
|
if ($this->accountService->countUsers() > 0) {
|
||||||
return redirect(
|
return redirect(
|
||||||
$this->channelService->channel->lucentUrl . "/login",
|
$this->channelService->channel->lucentUrl . "/login",
|
||||||
@@ -43,6 +47,10 @@ class AuthController
|
|||||||
|
|
||||||
public function postRegister(Request $request): Response
|
public function postRegister(Request $request): Response
|
||||||
{
|
{
|
||||||
|
if ($this->authService->isExternal()) {
|
||||||
|
abort(400);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->accountService->countUsers() > 0) {
|
if ($this->accountService->countUsers() > 0) {
|
||||||
abort(400);
|
abort(400);
|
||||||
}
|
}
|
||||||
@@ -61,6 +69,9 @@ class AuthController
|
|||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
|
if ($this->authService->isExternal()) {
|
||||||
|
return $this->authService->redirectHome();
|
||||||
|
}
|
||||||
if ($this->accountService->countUsers() == 0) {
|
if ($this->accountService->countUsers() == 0) {
|
||||||
return redirect(
|
return redirect(
|
||||||
$this->channelService->channel->lucentUrl . "/register",
|
$this->channelService->channel->lucentUrl . "/register",
|
||||||
@@ -76,6 +87,9 @@ class AuthController
|
|||||||
|
|
||||||
public function postLogin(Request $request)
|
public function postLogin(Request $request)
|
||||||
{
|
{
|
||||||
|
if ($this->authService->isExternal()) {
|
||||||
|
abort(400);
|
||||||
|
}
|
||||||
$this->authService->sendLoginEmail($request->input("email"));
|
$this->authService->sendLoginEmail($request->input("email"));
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -87,6 +101,10 @@ class AuthController
|
|||||||
// "token" => $request->input("token"),
|
// "token" => $request->input("token"),
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
|
if ($this->authService->isExternal()) {
|
||||||
|
abort(400);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
layout: "account",
|
layout: "account",
|
||||||
view: "verify",
|
view: "verify",
|
||||||
@@ -100,6 +118,10 @@ class AuthController
|
|||||||
|
|
||||||
public function postVerify(Request $request)
|
public function postVerify(Request $request)
|
||||||
{
|
{
|
||||||
|
if ($this->authService->isExternal()) {
|
||||||
|
abort(400);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->authService->login(
|
$this->authService->login(
|
||||||
$request->input("email"),
|
$request->input("email"),
|
||||||
@@ -113,6 +135,10 @@ class AuthController
|
|||||||
|
|
||||||
public function logout(): RedirectResponse
|
public function logout(): RedirectResponse
|
||||||
{
|
{
|
||||||
|
if ($this->authService->isExternal()) {
|
||||||
|
abort(400);
|
||||||
|
}
|
||||||
|
|
||||||
$this->session->flush();
|
$this->session->flush();
|
||||||
return redirect($this->channelService->channel->lucentUrl . "/login");
|
return redirect($this->channelService->channel->lucentUrl . "/login");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user