From f0ae648492e22e89bb42f0e9ae5dfbd8b5e0e8b9 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 2 Dec 2024 16:32:13 +0100 Subject: [PATCH] feat(frontend): force log out page --- Foxnouns.Frontend/src/lib/i18n/locales/en.json | 4 +++- .../routes/settings/force-log-out/+page.server.ts | 11 +++++++++++ .../src/routes/settings/force-log-out/+page.svelte | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Foxnouns.Frontend/src/routes/settings/force-log-out/+page.server.ts create mode 100644 Foxnouns.Frontend/src/routes/settings/force-log-out/+page.svelte diff --git a/Foxnouns.Frontend/src/lib/i18n/locales/en.json b/Foxnouns.Frontend/src/lib/i18n/locales/en.json index d221de5..73063c5 100644 --- a/Foxnouns.Frontend/src/lib/i18n/locales/en.json +++ b/Foxnouns.Frontend/src/lib/i18n/locales/en.json @@ -110,7 +110,9 @@ "username-update-success": "Successfully changed your username!", "create-member-title": "Create a new member", "create-member-name-label": "Member name", - "auth-remove-method": "Remove" + "auth-remove-method": "Remove", + "force-log-out-warning": "Make sure you're still able to log in before using this!", + "force-log-out-confirmation": "Are you sure you want to log out from all devices? If you just want to log out from this device, click the \"Log out\" button on your settings page." }, "yes": "Yes", "no": "No", diff --git a/Foxnouns.Frontend/src/routes/settings/force-log-out/+page.server.ts b/Foxnouns.Frontend/src/routes/settings/force-log-out/+page.server.ts new file mode 100644 index 0000000..0fb9f8f --- /dev/null +++ b/Foxnouns.Frontend/src/routes/settings/force-log-out/+page.server.ts @@ -0,0 +1,11 @@ +import { fastRequest } from "$api"; +import { clearToken } from "$lib"; +import { redirect } from "@sveltejs/kit"; + +export const actions = { + default: async ({ fetch, cookies }) => { + await fastRequest("POST", "/auth/force-log-out", { isInternal: true, fetch, cookies }, true); + clearToken(cookies); + redirect(303, "/"); + }, +}; diff --git a/Foxnouns.Frontend/src/routes/settings/force-log-out/+page.svelte b/Foxnouns.Frontend/src/routes/settings/force-log-out/+page.svelte new file mode 100644 index 0000000..6e31ddb --- /dev/null +++ b/Foxnouns.Frontend/src/routes/settings/force-log-out/+page.svelte @@ -0,0 +1,14 @@ + + +

{$t("settings.force-log-out-title")}

+ +

+ {$t("settings.force-log-out-confirmation")} + {$t("settings.force-log-out-warning")} +

+ +
+ +