Skip to content

Commit 476307f

Browse files
committed
add remove session to call refresh token
1 parent cfc6950 commit 476307f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/gotrue/lib/src/gotrue_client.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,7 @@ class GoTrueClient {
827827
final accessToken = currentSession?.accessToken;
828828

829829
if (scope != SignOutScope.others) {
830-
_currentSession = null;
831-
_currentUser = null;
830+
_removeSession();
832831
await _asyncStorage?.removeItem(
833832
key: '${Constants.defaultStorageKey}-code-verifier');
834833
notifyAllSubscribers(AuthChangeEvent.signedOut);
@@ -1116,6 +1115,11 @@ class GoTrueClient {
11161115
_currentUser = session.user;
11171116
}
11181117

1118+
void _removeSession() {
1119+
_currentSession = null;
1120+
_currentUser = null;
1121+
}
1122+
11191123
/// Generates a new JWT.
11201124
///
11211125
/// To prevent multiple simultaneous requests it catches an already ongoing request by using the global [_refreshTokenCompleter].
@@ -1150,6 +1154,7 @@ class GoTrueClient {
11501154
return data;
11511155
} on AuthException catch (error, stack) {
11521156
if (error is! AuthRetryableFetchException) {
1157+
_removeSession();
11531158
notifyAllSubscribers(AuthChangeEvent.signedOut);
11541159
} else {
11551160
_onAuthStateChangeController.addError(error, stack);

0 commit comments

Comments
 (0)