You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I've run into a problem related to invalid/expired confirmation links when signing up with email. The (relevant part of the) expired link looks as follows: com.example:///email-signup?error=access_denied&error_code=4&error_description=Email+link+is+invalid+or+has+expired#<...>. I was planning on handling this by checking the error_code query parameter in my app, and giving an appropriate message to the user. The issue, however, is that the deeplink navigation triggers supabase to call GoTrueClient.getSessionFromUrl, which raises an exception. So it never makes its way to the router. I've not been able to neither catch nor disable this exception, meaning that the app crashes whenever a user presses an expired link. I've tried the following without success:
Use the onException callback in my GoRouter, but this doesn't seem to be triggered.
Initialize supabase with client option setting detectSessionInUri = false.
I have a try-catch around the supabase.auth.signUp call, but this doesn't matter because the exception is raised when the link is clicked, not when signUp is called.
Setup a flutter app with supabase_flutter, email+password authentication and GoRouter (though I don't think the last one is necessary)
Set up deep link navigation from the confirmation email link
Sign up, wait for the link to expire, and click it. (Alternatively, resend a new link and then click the old link).
Expected behavior
Clicking the expired link should navigate to that link and not raise an exception. (Alternatively; make it possible to catch that exception.)
Screenshots
NA
Version (please complete the following information):
On Linux/macOS
Additional context
Deep linking and navigation in this particular app in general works fine, so I'm confident this has nothing to do with the general routing setup.
The text was updated successfully, but these errors were encountered:
You probably listen to the onAuthStateChanged stream without providing an onError callback to the listen() method. So exceptions that are added to the stream are not caught.
You're right, thanks! I thought I'd checked this, but had forgotten about the other auth state change listener I have in main.dart which was causing the issue. Thanks again :-)
Follow-up question: I now have an onAuthChangeState listener in the screen in question. I'm able to catch the error in the onError callback and provide a message to the user. However, if I navigate to another screen and then into the screen with the listener again, the same onError is triggered once again. I have made sure to cancel the subscription on dispose so I find it strange that the error re-appears the next time I navigate to the screen (also happens on consecutive navigations). I haven't been able to find any good resources on this. Could this be an issue with onAuthStateChange? My code related to the auth state listener looks as follows:
StreamSubscription? authSubscription;
@override
initState() {
super.initState();
authSubscription = supabase.auth.onAuthStateChange.listen(
(data) {
final AuthChangeEvent event = data.event;
if (event == AuthChangeEvent.signedIn) {
// ...
}
},
onError: (Object error) {
if (error is AuthException && error.statusCode == "403") {
// Logic to displaying a modal. This is triggered over and over
} else {
// This is some other error we don't expect here, so we don't take care of it
throw error;
}
},
);
}
@override
void dispose() {
authSubscription?.cancel();
authSubscription = null;
super.dispose();
}
Describe the bug
I've run into a problem related to invalid/expired confirmation links when signing up with email. The (relevant part of the) expired link looks as follows:
com.example:///email-signup?error=access_denied&error_code=4&error_description=Email+link+is+invalid+or+has+expired#<...>
. I was planning on handling this by checking theerror_code
query parameter in my app, and giving an appropriate message to the user. The issue, however, is that the deeplink navigation triggers supabase to callGoTrueClient.getSessionFromUrl
, which raises an exception. So it never makes its way to the router. I've not been able to neither catch nor disable this exception, meaning that the app crashes whenever a user presses an expired link. I've tried the following without success:detectSessionInUri = false
.supabase.auth.signUp
call, but this doesn't matter because the exception is raised when the link is clicked, not whensignUp
is called.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Clicking the expired link should navigate to that link and not raise an exception. (Alternatively; make it possible to catch that exception.)
Screenshots
NA
Version (please complete the following information):
On Linux/macOS
On Windows
NA
Additional context
Deep linking and navigation in this particular app in general works fine, so I'm confident this has nothing to do with the general routing setup.
The text was updated successfully, but these errors were encountered: