Auth not set on server side with link (magic link) login
See original GitHub issueVersion
@nuxtjs/supabase: v0.1.9 nuxt: v3.0.0-rc.1
Steps to reproduce
Set up a login form using the just the email to receive a magic link
const { session, error } = await client.auth.signIn({ email: email.value })
Use a middleware like this
export default defineNuxtRouteMiddleware((to) => {
const user = useSupabaseUser()
if (!(user.value))
return navigateTo({ name: 'login', query: { redirect: to.path } })
})
What is Expected?
The user should be set on the server side.
What is actually happening?
The token on the server side plugin is null:
export default defineNuxtPlugin(async () => {
const user = useSupabaseUser();
const client = useSupabaseClient();
const token = useSupabaseToken();
if (!token.value) {
return;
}
const { user: supabaseUser, error } = await client.auth.api.getUser(token.value);
user.value = error ? null : supabaseUser;
});
Therefore the middleware redirects the user to the login and the user only becomes available after the middleware has run, leaving the user on the login page. A fix would involve watching the user, but thats still leads to the login page shortly showing up before the user is redirected again.
This issue is linked to #28 but singles out the ssr issue when using magic links
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Auth not set on server side with link (magic link) login · Issue #32
middleware has run, leaving the user on the login page. A fix would involve watching the user, but thats still leads to the...
Read more >Frequently Asked Questions - Documentation - Magic.link
#General. #Can the magic link redirect to a specific URL? Yes! When calling the loginWithMagicLink sdk method you can pass in an optional...
Read more >Is passwordless magic link only intended for client-side ...
Hello everybody,. I currently have a React app that uses Auth0's magic link authentication method using 'auth0-js'.
Read more >How to implement Magic Link Authentication with Next.js and ...
This article will cover magic-link authentication basics using Next.js and Altogic, a backend-as-a-service platform using its client library ...
Read more >How to implement Magic Link Authentication with Next.js and ...
For that authentication method, the primary condition is that the link needs to be safe and can not be able to manipulated from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @nosizejosh, that’s a way I found to avoid the display of the login form highlited by @mwohlan. That was just a proposition.
Thank you @larbish