From 3d566086003efd952cd1535ee9d971dab5d58a15 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Thu, 1 Aug 2024 22:43:27 +0900
Subject: refactor(frontend): simplify login check

---
 frontend/app/routes/login.tsx | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

(limited to 'frontend/app/routes/login.tsx')

diff --git a/frontend/app/routes/login.tsx b/frontend/app/routes/login.tsx
index 95effaa..1c861fc 100644
--- a/frontend/app/routes/login.tsx
+++ b/frontend/app/routes/login.tsx
@@ -4,23 +4,19 @@ import type {
 	MetaFunction,
 } from "@remix-run/node";
 import { Form } from "@remix-run/react";
-import { authenticator } from "../.server/auth";
+import { ensureUserNotLoggedIn, login } from "../.server/auth";
 
 export const meta: MetaFunction = () => {
 	return [{ title: "Login | iOSDC Japan 2024 Albatross.swift" }];
 };
 
 export async function loader({ request }: LoaderFunctionArgs) {
-	return await authenticator.isAuthenticated(request, {
-		successRedirect: "/dashboard",
-	});
+	return await ensureUserNotLoggedIn(request);
 }
 
 export async function action({ request }: ActionFunctionArgs) {
-	return await authenticator.authenticate("default", request, {
-		successRedirect: "/dashboard",
-		failureRedirect: "/login",
-	});
+	await login(request);
+	return null;
 }
 
 export default function Login() {
-- 
cgit v1.2.3-70-g09d2

