mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
YADESK-630 add account
This commit is contained in:
parent
52123644a7
commit
411d744537
@ -272,7 +272,7 @@ class MainViewModel : ViewModel() {
|
||||
.toJson(session.deviceId)
|
||||
.toString()
|
||||
|
||||
result.success(jsonResult)
|
||||
returnSuccess(result, jsonResult)
|
||||
}
|
||||
}
|
||||
} catch (cause: Throwable) {
|
||||
|
@ -177,9 +177,24 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
|
||||
await _api.addAccount(credentialUri.toString(), requireTouch);
|
||||
|
||||
var result = jsonDecode(resultString);
|
||||
final pair = OathPair(OathCredential.fromJson(result['credential']),
|
||||
result['code'] != null ? OathCode.fromJson(result['code']) : null);
|
||||
refresh();
|
||||
final newCredential = OathCredential.fromJson(result['credential']);
|
||||
final newCode =
|
||||
result['code'] != null ? OathCode.fromJson(result['code']) : null;
|
||||
final pair = OathPair(newCredential, newCode);
|
||||
|
||||
if (mounted) {
|
||||
final newState = state!.toList();
|
||||
|
||||
// this should not happen when adding a new credential
|
||||
// but if we
|
||||
final index = newState.indexWhere((e) => e.credential == newCredential);
|
||||
if (index > 0) {
|
||||
newState.removeAt(index);
|
||||
}
|
||||
|
||||
newState.add(pair);
|
||||
state = newState;
|
||||
}
|
||||
|
||||
return pair.credential;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user