bugfixes, better background operation robustness and platform-specific error handling
This commit is contained in:
@@ -36,7 +36,15 @@ class MarianumConnectAuthInterceptor extends Interceptor {
|
||||
// Token mitschicken statt ein eigenes 401 einzufangen.
|
||||
final pending = _pendingReLogin;
|
||||
if (pending != null) await pending;
|
||||
final token = await _tokenStorage.readToken();
|
||||
// Reading the keystore can throw while the device is locked (iOS
|
||||
// errSecInteractionNotAllowed on background requests). Degrade to an
|
||||
// unauthenticated request instead of surfacing a platform error.
|
||||
String? token;
|
||||
try {
|
||||
token = await _tokenStorage.readToken();
|
||||
} catch (_) {
|
||||
token = null;
|
||||
}
|
||||
if (token != null && token.isNotEmpty) {
|
||||
options.headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user