signOut method
Signs out the current user, if there is a logged in user.
scope
determines which sessions should be logged out.
If using SignOutScope.others scope, no AuthChangeEvent.signedOut event is fired!
Implementation
Future<void> signOut({
SignOutScope scope = SignOutScope.local,
}) async {
final accessToken = currentSession?.accessToken;
if (scope != SignOutScope.others) {
_removeSession();
await _asyncStorage?.removeItem(
key: '${Constants.defaultStorageKey}-code-verifier');
notifyAllSubscribers(AuthChangeEvent.signedOut);
}
if (accessToken != null) {
try {
await admin.signOut(accessToken, scope: scope);
} on AuthException catch (error) {
// ignore 401s since an invalid or expired JWT should sign out the current session
// ignore 403s since user might not exist anymore
// ignore 404s since user might not exist anymore
if (error.statusCode != '401' &&
error.statusCode != '403' &&
error.statusCode != '404') {
rethrow;
}
}
}
}