Skip to content

Commit

Permalink
add remove session to call refresh token
Browse files Browse the repository at this point in the history
  • Loading branch information
dshukertjr committed Jun 10, 2024
1 parent cfc6950 commit 476307f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/gotrue/lib/src/gotrue_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,7 @@ class GoTrueClient {
final accessToken = currentSession?.accessToken;

if (scope != SignOutScope.others) {
_currentSession = null;
_currentUser = null;
_removeSession();
await _asyncStorage?.removeItem(
key: '${Constants.defaultStorageKey}-code-verifier');
notifyAllSubscribers(AuthChangeEvent.signedOut);
Expand Down Expand Up @@ -1116,6 +1115,11 @@ class GoTrueClient {
_currentUser = session.user;
}

void _removeSession() {
_currentSession = null;
_currentUser = null;
}

/// Generates a new JWT.
///
/// To prevent multiple simultaneous requests it catches an already ongoing request by using the global [_refreshTokenCompleter].
Expand Down Expand Up @@ -1150,6 +1154,7 @@ class GoTrueClient {
return data;
} on AuthException catch (error, stack) {
if (error is! AuthRetryableFetchException) {
_removeSession();
notifyAllSubscribers(AuthChangeEvent.signedOut);
} else {
_onAuthStateChangeController.addError(error, stack);
Expand Down

0 comments on commit 476307f

Please sign in to comment.