supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
656 stars 154 forks source link

Reset password, Supabase, Flutter. Cannot change passord after back in app. Auth = null #949

Closed nilshv closed 4 days ago

nilshv commented 4 days ago

Short story: My flutter app works great with Supabase. My login works, change e-mail works but my reset password dose not work. I have implemented deep link. I execute await supabase.auth.updateUser(user) witch sends me the password reset email. After clicking the link my app opens and I am redirected to my forgot password page. The link I receive in my app is parkeringsapp://parkering/glemtpassord?code=bb1de446-ddfc-43c3xxxxxxxxxxxxxxx The user enters new password and I execute UserAttributes user = UserAttributes(password: password); var response = await supabase.auth.updateUser(user); But gets a exception with Not logged in. The Supabase.auth.user is null. And here I am stuck now for a week. As I have read clicking the link should log in the user, but that doesn't seams to happen to me.

dshukertjr commented 4 days ago

Clicking on the recovery link does sign the user in. Do you use app_link in your app? If so, the deep link callback within supabase_flutter is not being fired because in app_link you cannot have multiple listeners. In that case you can call supabase.auth.getSessionFromUrl() manually within your app_link callback.

If the above does not apply to you, try to create a fresh new Flutter application with a magic link login and see if you can successfully authenticate with a magic link login. Magic link and password reset link work the exact same way, so if you can make magic link login work, you can implement the magic link login the same way.