From 05ae4bfb1fd924e88b451a80ce5fc6d26918e750 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Sun, 25 Aug 2024 14:37:32 +0200 Subject: [PATCH] Redirect to profile after signin --- components/global/user/CTA.vue | 4 +++- nuxt.config.ts | 5 ++++- pages/i/calendar/[id].vue | 2 +- pages/i/world/[id].vue | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/global/user/CTA.vue b/components/global/user/CTA.vue index 857c72c..04fba1a 100644 --- a/components/global/user/CTA.vue +++ b/components/global/user/CTA.vue @@ -8,6 +8,7 @@ const router = useRouter() const { auth } = useSupabaseClient() const user = useSupabaseUser() const userMeta = computed(() => user.value?.user_metadata) +const profileUrl: string = `${useRequestURL().origin}/i/` const menuOpened = ref(false) @@ -24,7 +25,8 @@ async function handleGoogleLogin() { queryParams: { access_type: "offline", prompt: "consent" - } + }, + redirectTo: profileUrl } }) } catch (err) { diff --git a/nuxt.config.ts b/nuxt.config.ts index fa90f58..113cde9 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -14,7 +14,10 @@ export default defineNuxtConfig({ css: ["~/assets/main.css"], supabase: { - redirect: false + redirectOptions: { + login: "/", + callback: "/i" + } }, postcss: { diff --git a/pages/i/calendar/[id].vue b/pages/i/calendar/[id].vue index f647778..4883481 100644 --- a/pages/i/calendar/[id].vue +++ b/pages/i/calendar/[id].vue @@ -12,7 +12,7 @@ definePageMeta({ const user = useSupabaseUser() // Redirect user back home when they log out on the page -watch(user, (n, _o) => { +watch(user, (n) => { if (!n) { navigateTo("/") } diff --git a/pages/i/world/[id].vue b/pages/i/world/[id].vue index dcfbdf1..b82674d 100644 --- a/pages/i/world/[id].vue +++ b/pages/i/world/[id].vue @@ -22,7 +22,7 @@ definePageMeta({ const user = useSupabaseUser() // Redirect user back home when they log out on the page -watch(user, (n, _o) => { +watch(user, (n) => { if (!n) { navigateTo("/") }