fixed stale state after logout and replayed or lost share intents
This commit is contained in:
@@ -88,17 +88,29 @@ class MarianumConnectAuthInterceptor extends Interceptor {
|
||||
|
||||
Future<bool> _performReLogin() async {
|
||||
if (!AccountData().isPopulated()) return false;
|
||||
final username = AccountData().getUsername();
|
||||
// A background engine (widget task) keeps the account it loaded. When
|
||||
// the app signed that account out, its revoked token answers 401 — a
|
||||
// re-login would mint a fresh token for it into the shared keystore.
|
||||
if (await AccountData().readStoredUsername() != username) return false;
|
||||
try {
|
||||
await _loginClient.run(
|
||||
username: AccountData().getUsername(),
|
||||
username: username,
|
||||
password: AccountData().getPassword(),
|
||||
tokenName: await DeviceTokenName.resolve(),
|
||||
);
|
||||
return true;
|
||||
} catch (_) {
|
||||
await _tokenStorage.clear();
|
||||
if (await AccountData().readStoredUsername() == username) {
|
||||
await _tokenStorage.clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final stored = await AccountData().readStoredUsername();
|
||||
if (stored == username) return true;
|
||||
// Signed out during the login: drop the orphaned token, unless another
|
||||
// account already stored its own.
|
||||
if (stored == null) await _tokenStorage.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<Response<dynamic>> _retryWithFreshToken(
|
||||
|
||||
Reference in New Issue
Block a user