Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onAuthStateChange only fires "INITIAL_SESSION" event? #330

Open
tedik123 opened this issue Feb 4, 2024 · 0 comments
Open

onAuthStateChange only fires "INITIAL_SESSION" event? #330

tedik123 opened this issue Feb 4, 2024 · 0 comments
Labels
question Further information is requested

Comments

@tedik123
Copy link

tedik123 commented Feb 4, 2024

Hello I'm not sure what I'm doing wrong because this setup worked on another project a bit ago but onAuthStateChange does not fire besides the initial session event. I believe I am successfully logging in with google OAuth because it does redirect me back to localhost and if I read the session data I have my tokens and basic google account info. Sign in only fires if I am signed in and then I switch tabs and back to it, but not when I actually log in. This is all inside a userStore using pinia and the userStore is always on the page. Any idea what I'm doing wrong?

const supabase = useSupabaseClient()
// use google oAuth
async function handleLogin() {
       await supabase.auth.signInWithOAuth({
                provider: 'google',
       })
}

supabase.auth.onAuthStateChange(async (event, session) => {
        console.log('event', event)
        switch (event) {
            case "INITIAL_SESSION":
                console.log("Initial session", session)
                break
            case 'SIGNED_IN':
                console.log('User signed in');
                await handleSignInEvent()
                break;
            
        }
 });

@tedik123 tedik123 added the question Further information is requested label Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant