From 5c178f99ae2d9321145c21f9886fcfe0824d73f6 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Wed, 9 Jul 2025 07:19:40 +0200 Subject: [PATCH 01/13] feat: add fetchInstanceStats and sendVerificationEmail to api composable --- composables/api.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/composables/api.ts b/composables/api.ts index 603f71f..d2ca7a0 100644 --- a/composables/api.ts +++ b/composables/api.ts @@ -1,4 +1,4 @@ -import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse } from "~/types/interfaces"; +import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse, StatsResponse } from "~/types/interfaces"; export const useApi = () => { async function fetchGuilds(): Promise { @@ -41,6 +41,15 @@ export const useApi = () => { return await fetchWithApi(`/channels/${channelId}/messages/${messageId}`); } + async function fetchInstanceStats(apiBase: string): Promise { + return await $fetch(`${apiBase}/stats`, { method: "GET" }); + } + + async function sendVerificationEmail(): Promise { + const email = useAuth().user.value?.email; + await fetchWithApi("/auth/verify-email", { method: "POST", body: { email } }); + } + return { fetchGuilds, fetchGuild, @@ -51,6 +60,8 @@ export const useApi = () => { fetchUsers, fetchUser, fetchMessages, - fetchMessage + fetchMessage, + fetchInstanceStats, + sendVerificationEmail } } From 04689e57ea34e936170049f3a76f7adb551c1bad Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Wed, 9 Jul 2025 07:21:16 +0200 Subject: [PATCH 02/13] feat: remove old logout and other auth functions from login/register page --- layouts/auth.vue | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/layouts/auth.vue b/layouts/auth.vue index b7d5c5e..dc65e96 100644 --- a/layouts/auth.vue +++ b/layouts/auth.vue @@ -20,30 +20,7 @@
- Instance URL is set to {{ instanceUrl }} -
-
- You're logged in! -
-
- -
- -
-
- -
-
-
- -
-
- -
-
- -
+ Instance URL is set to {{ instanceUrl }}
From 397e94798f4a0d398040c9612aa1b6e3c501ebe7 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Wed, 9 Jul 2025 07:21:49 +0200 Subject: [PATCH 03/13] feat: remove unused type import --- layouts/auth.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/layouts/auth.vue b/layouts/auth.vue index dc65e96..d58a97f 100644 --- a/layouts/auth.vue +++ b/layouts/auth.vue @@ -28,7 +28,6 @@ \ No newline at end of file From 84aa1f95fe555a60ff0f23cb8e4e320afaf3e090 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Wed, 9 Jul 2025 07:30:06 +0200 Subject: [PATCH 12/13] feat: add auto redirection in verify-email page --- pages/verify-email.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pages/verify-email.vue b/pages/verify-email.vue index cae02ea..f160a1d 100644 --- a/pages/verify-email.vue +++ b/pages/verify-email.vue @@ -15,6 +15,12 @@ const token = useRoute().query.token; try { const res = await fetchWithApi("/auth/verify-email", { query: { token } }); console.log("hi"); + const query = useRoute().query; + if (query.redirect_to) { + await navigateTo(`/?redirect_to=${query.redirect_to}`); + } else { + await navigateTo("/"); + } } catch (error) { console.error("Error verifying email:", error); errorMessage.value = error; From 4b6dc03b136e3d19662f1f87eb09753c655d5c27 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Wed, 9 Jul 2025 07:30:46 +0200 Subject: [PATCH 13/13] feat: refresh page when email is changed and instance requires verification --- components/Settings/UserSettings/Account.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/Settings/UserSettings/Account.vue b/components/Settings/UserSettings/Account.vue index 85589e7..a08cffc 100644 --- a/components/Settings/UserSettings/Account.vue +++ b/components/Settings/UserSettings/Account.vue @@ -43,6 +43,14 @@ async function changeEmail() { body: formData }) + const apiBase = useCookie("api_base").value; + + if (apiBase) { + const stats = await useApi().fetchInstanceStats(apiBase); + if (stats.email_verification_required) { + return window.location.reload(); + } + } alert('success!!') } catch (error: any) { if (error?.response?.status !== 200) {