Merge branch 'krille/fix-broken-init' into 'main'
fix: Logout after failed init See merge request famedly/famedlysdk!617
This commit is contained in:
commit
b8053ff28d
|
|
@ -351,17 +351,12 @@ class Client extends MatrixApi {
|
||||||
response.userId == null) {
|
response.userId == null) {
|
||||||
throw Exception('Registered but token, device ID or user ID is null.');
|
throw Exception('Registered but token, device ID or user ID is null.');
|
||||||
}
|
}
|
||||||
try {
|
await init(
|
||||||
await init(
|
newToken: response.accessToken,
|
||||||
newToken: response.accessToken,
|
newUserID: response.userId,
|
||||||
newUserID: response.userId,
|
newHomeserver: homeserver,
|
||||||
newHomeserver: homeserver,
|
newDeviceName: initialDeviceDisplayName ?? '',
|
||||||
newDeviceName: initialDeviceDisplayName ?? '',
|
newDeviceID: response.deviceId);
|
||||||
newDeviceID: response.deviceId);
|
|
||||||
} catch (_) {
|
|
||||||
await logout().catchError((_) => null);
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -401,19 +396,14 @@ class Client extends MatrixApi {
|
||||||
loginResp.userId == null) {
|
loginResp.userId == null) {
|
||||||
throw Exception('Registered but token, device ID or user ID is null.');
|
throw Exception('Registered but token, device ID or user ID is null.');
|
||||||
}
|
}
|
||||||
try {
|
await init(
|
||||||
await init(
|
newToken: loginResp.accessToken,
|
||||||
newToken: loginResp.accessToken,
|
newUserID: loginResp.userId,
|
||||||
newUserID: loginResp.userId,
|
newHomeserver: homeserver,
|
||||||
newHomeserver: homeserver,
|
newDeviceName: initialDeviceDisplayName ?? '',
|
||||||
newDeviceName: initialDeviceDisplayName ?? '',
|
newDeviceID: loginResp.deviceId,
|
||||||
newDeviceID: loginResp.deviceId,
|
);
|
||||||
);
|
return loginResp;
|
||||||
return loginResp;
|
|
||||||
} catch (_) {
|
|
||||||
await logout().catchError((_) => null);
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a logout command to the homeserver and clears all local data,
|
/// Sends a logout command to the homeserver and clears all local data,
|
||||||
|
|
@ -843,7 +833,7 @@ class Client extends MatrixApi {
|
||||||
return _sync();
|
return _sync();
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logs().e('Initialization failed', e, s);
|
Logs().e('Initialization failed', e, s);
|
||||||
clear();
|
await logout().catchError((_) => null);
|
||||||
onLoginStateChanged.addError(e, s);
|
onLoginStateChanged.addError(e, s);
|
||||||
_initLock = false;
|
_initLock = false;
|
||||||
rethrow;
|
rethrow;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue