aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-30 23:47:29 +0900
committernsfisis <nsfisis@gmail.com>2024-07-30 23:47:29 +0900
commit422605f7a62ae3d32573387ab45e739b497357c6 (patch)
tree72534a499914f492a26c246930159a8d4ae532f1
parentdb0721e9820f399727b933088a276184e9565c9d (diff)
downloadphperkaigi-2025-albatross-422605f7a62ae3d32573387ab45e739b497357c6.tar.gz
phperkaigi-2025-albatross-422605f7a62ae3d32573387ab45e739b497357c6.tar.zst
phperkaigi-2025-albatross-422605f7a62ae3d32573387ab45e739b497357c6.zip
feat(frontend): implement /logout
-rw-r--r--frontend/app/routes/dashboard.tsx12
-rw-r--r--frontend/app/routes/logout.tsx6
2 files changed, 17 insertions, 1 deletions
diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx
index d7cad6c..9afee86 100644
--- a/frontend/app/routes/dashboard.tsx
+++ b/frontend/app/routes/dashboard.tsx
@@ -1,5 +1,5 @@
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
-import { Link, useLoaderData } from "@remix-run/react";
+import { Link, useLoaderData, Form } from "@remix-run/react";
import { isAuthenticated } from "../.server/auth";
import { apiClient } from "../.server/api/client";
@@ -68,6 +68,16 @@ export default function Dashboard() {
))}
</ul>
</div>
+ <div>
+ <Form method="post" action="/logout">
+ <button
+ className="mt-6 px-6 py-2 text-white bg-red-500 hover:bg-red-700 rounded"
+ type="submit"
+ >
+ Logout
+ </button>
+ </Form>
+ </div>
</div>
</div>
);
diff --git a/frontend/app/routes/logout.tsx b/frontend/app/routes/logout.tsx
new file mode 100644
index 0000000..f48081d
--- /dev/null
+++ b/frontend/app/routes/logout.tsx
@@ -0,0 +1,6 @@
+import type { ActionFunctionArgs } from "@remix-run/node";
+import { authenticator } from "../.server/auth";
+
+export async function action({ request }: ActionFunctionArgs) {
+ await authenticator.logout(request, { redirectTo: "/" });
+}