-
Link a new email address
+
{$t("auth.link-email-header")}
diff --git a/Foxnouns.Frontend/src/routes/settings/auth/remove-method/[id]/+page.server.ts b/Foxnouns.Frontend/src/routes/settings/auth/remove-method/[id]/+page.server.ts
new file mode 100644
index 0000000..b2c6318
--- /dev/null
+++ b/Foxnouns.Frontend/src/routes/settings/auth/remove-method/[id]/+page.server.ts
@@ -0,0 +1,40 @@
+import { fastRequest } from "$api";
+import ApiError, { ErrorCode } from "$api/error.js";
+import log from "$lib/log.js";
+import { error, isRedirect, redirect } from "@sveltejs/kit";
+
+export const load = async ({ parent, params }) => {
+ const data = await parent();
+ if (data.user.auth_methods.length < 2) {
+ error(403, {
+ message: "You cannot remove your last authentication method.",
+ status: 403,
+ code: ErrorCode.LastAuthMethod,
+ });
+ }
+
+ const authMethod = data.meUser!.auth_methods.find((m) => m.id === params.id);
+ if (!authMethod) {
+ error(404, {
+ message: "No authentication method with that ID found.",
+ status: 404,
+ code: ErrorCode.GenericApiError,
+ });
+ }
+
+ return { authMethod };
+};
+
+export const actions = {
+ default: async ({ params, fetch, cookies }) => {
+ try {
+ fastRequest("DELETE", "/auth/methods/" + params.id, { fetch, cookies, isInternal: true });
+ redirect(303, "/settings/auth?alert=auth-method-remove-success");
+ } catch (e) {
+ if (isRedirect(e)) throw e;
+ if (e instanceof ApiError) return { error: e.obj };
+ log.error("Could not remove auth method %s:", params.id, e);
+ throw e;
+ }
+ },
+};
diff --git a/Foxnouns.Frontend/src/routes/settings/auth/remove-method/[id]/+page.svelte b/Foxnouns.Frontend/src/routes/settings/auth/remove-method/[id]/+page.svelte
new file mode 100644
index 0000000..22b40ad
--- /dev/null
+++ b/Foxnouns.Frontend/src/routes/settings/auth/remove-method/[id]/+page.svelte
@@ -0,0 +1,44 @@
+
+
+
+ {unlinkHeader(data.authMethod.type)} • pronouns.cc
+
+
+
+
{unlinkHeader(data.authMethod.type)}
+ {#if form?.error}
+
+ {/if}
+
+ {$t("auth.unlink-confirmation-1", {
+ username: data.authMethod.remote_username || data.authMethod.remote_id,
+ })}
+ {$t("auth.unlink-confirmation-2")}
+
+
+