chore: Improved error handling for recovery key
This commit is contained in:
parent
74b1553662
commit
2af8691536
2 changed files with 17 additions and 9 deletions
|
|
@ -266,6 +266,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
),
|
),
|
||||||
hintText: L10n.of(context)!.recoveryKey,
|
hintText: L10n.of(context)!.recoveryKey,
|
||||||
errorText: _recoveryKeyInputError,
|
errorText: _recoveryKeyInputError,
|
||||||
|
errorMaxLines: 2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
@ -290,6 +291,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
final key = _recoveryKeyTextEditingController
|
final key = _recoveryKeyTextEditingController
|
||||||
.text
|
.text
|
||||||
.trim();
|
.trim();
|
||||||
|
if (key.isEmpty) return;
|
||||||
await bootstrap.newSsssKey!.unlock(
|
await bootstrap.newSsssKey!.unlock(
|
||||||
keyOrPassphrase: key,
|
keyOrPassphrase: key,
|
||||||
);
|
);
|
||||||
|
|
@ -317,6 +319,11 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
() => _recoveryKeyInputError =
|
() => _recoveryKeyInputError =
|
||||||
e.toLocalizedString(context),
|
e.toLocalizedString(context),
|
||||||
);
|
);
|
||||||
|
} on FormatException catch (_) {
|
||||||
|
setState(
|
||||||
|
() => _recoveryKeyInputError =
|
||||||
|
L10n.of(context)!.wrongRecoveryKey,
|
||||||
|
);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
ErrorReporter(
|
ErrorReporter(
|
||||||
context,
|
context,
|
||||||
|
|
|
||||||
|
|
@ -163,15 +163,16 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||||
List<IdentityProvider>? get identityProviders {
|
List<IdentityProvider>? get identityProviders {
|
||||||
final loginTypes = _rawLoginTypes;
|
final loginTypes = _rawLoginTypes;
|
||||||
if (loginTypes == null) return null;
|
if (loginTypes == null) return null;
|
||||||
final List? rawProviders = loginTypes.tryGetList('flows')!.singleWhere(
|
final List? rawProviders =
|
||||||
(flow) => flow['type'] == AuthenticationTypes.sso,
|
loginTypes.tryGetList('flows')?.singleWhereOrNull(
|
||||||
)['identity_providers'] ??
|
(flow) => flow['type'] == AuthenticationTypes.sso,
|
||||||
[
|
)['identity_providers'] ??
|
||||||
{'id': null},
|
[
|
||||||
];
|
{'id': null},
|
||||||
final list = (rawProviders as List)
|
];
|
||||||
.map((json) => IdentityProvider.fromJson(json))
|
if (rawProviders == null) return null;
|
||||||
.toList();
|
final list =
|
||||||
|
rawProviders.map((json) => IdentityProvider.fromJson(json)).toList();
|
||||||
if (PlatformInfos.isCupertinoStyle) {
|
if (PlatformInfos.isCupertinoStyle) {
|
||||||
list.sort((a, b) => a.brand == 'apple' ? -1 : 1);
|
list.sort((a, b) => a.brand == 'apple' ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue