From edd65f13017879d590260470bf6c6570912e0061 Mon Sep 17 00:00:00 2001 From: Michael Dausmann Date: Mon, 2 Jan 2023 20:53:04 +1100 Subject: [PATCH] Horrible redirect kludge to fix login flow, tidy up and readme --- README.md | 8 +++++--- middleware/auth.ts | 9 +-------- pages/dashboard.vue | 8 ++++---- pages/index.vue | 12 +++++++++--- pages/login.vue | 3 ++- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 87d5c8e..7d690ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Nuxt 3 Minimal Starter +# Nuxt 3 Minimal Starter + Supabase + OAuth Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. @@ -41,8 +41,8 @@ npm run preview Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. -# GENESIS STEPS -This is what I did to create the boilerplate, it is here for your interest and for my memory, you don't need to repeat these. +# Steps to Create +This is what I did to create the project including all the extra fiddly stuff. Putting this here so I don't forget. Follow instructions from here https://nuxt.com/docs/getting-started/installation @@ -69,3 +69,5 @@ modules: ['@nuxtjs/supabase'] ``` Follow these instructions to add google oath https://supabase.com/docs/guides/auth/social-login/auth-google + +Then I frigged around trying to get the nuxt-supabase module to work properly for the oauth flow. It's a bit of a mess TBH. diff --git a/middleware/auth.ts b/middleware/auth.ts index 7cb249e..a14df92 100644 --- a/middleware/auth.ts +++ b/middleware/auth.ts @@ -1,13 +1,6 @@ export default defineNuxtRouteMiddleware((to) => { const user = useSupabaseUser(); if(!user.value && to.path === '/dashboard'){ - console.log('auth - navigating to login (from dashboard)') navigateTo('login'); - } else if(user.value && to.path === '/') { - console.log('auth - navigating to dashboard (from root)') - navigateTo('dashboard'); - } else if(user.value && to.path === '/login') { - console.log('auth - navigating to dashboard (from login)') - navigateTo('dashboard'); - } + } }) \ No newline at end of file diff --git a/pages/dashboard.vue b/pages/dashboard.vue index 275a2aa..0add2ad 100644 --- a/pages/dashboard.vue +++ b/pages/dashboard.vue @@ -1,8 +1,8 @@