chore: Improved error handling for recovery key

pull/830/head
Krille 2 years ago
parent 74b1553662
commit 2af8691536
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -266,6 +266,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
),
hintText: L10n.of(context)!.recoveryKey,
errorText: _recoveryKeyInputError,
errorMaxLines: 2,
),
),
const SizedBox(height: 16),
@ -290,6 +291,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
final key = _recoveryKeyTextEditingController
.text
.trim();
if (key.isEmpty) return;
await bootstrap.newSsssKey!.unlock(
keyOrPassphrase: key,
);
@ -317,6 +319,11 @@ class BootstrapDialogState extends State<BootstrapDialog> {
() => _recoveryKeyInputError =
e.toLocalizedString(context),
);
} on FormatException catch (_) {
setState(
() => _recoveryKeyInputError =
L10n.of(context)!.wrongRecoveryKey,
);
} catch (e, s) {
ErrorReporter(
context,

@ -163,15 +163,16 @@ class HomeserverPickerController extends State<HomeserverPicker> {
List<IdentityProvider>? get identityProviders {
final loginTypes = _rawLoginTypes;
if (loginTypes == null) return null;
final List? rawProviders = loginTypes.tryGetList('flows')!.singleWhere(
(flow) => flow['type'] == AuthenticationTypes.sso,
)['identity_providers'] ??
[
{'id': null},
];
final list = (rawProviders as List)
.map((json) => IdentityProvider.fromJson(json))
.toList();
final List? rawProviders =
loginTypes.tryGetList('flows')?.singleWhereOrNull(
(flow) => flow['type'] == AuthenticationTypes.sso,
)['identity_providers'] ??
[
{'id': null},
];
if (rawProviders == null) return null;
final list =
rawProviders.map((json) => IdentityProvider.fromJson(json)).toList();
if (PlatformInfos.isCupertinoStyle) {
list.sort((a, b) => a.brand == 'apple' ? -1 : 1);
}

Loading…
Cancel
Save