mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 18:22:39 +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)
|
.toJson(session.deviceId)
|
||||||
.toString()
|
.toString()
|
||||||
|
|
||||||
result.success(jsonResult)
|
returnSuccess(result, jsonResult)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (cause: Throwable) {
|
} catch (cause: Throwable) {
|
||||||
|
@ -177,9 +177,24 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
|
|||||||
await _api.addAccount(credentialUri.toString(), requireTouch);
|
await _api.addAccount(credentialUri.toString(), requireTouch);
|
||||||
|
|
||||||
var result = jsonDecode(resultString);
|
var result = jsonDecode(resultString);
|
||||||
final pair = OathPair(OathCredential.fromJson(result['credential']),
|
final newCredential = OathCredential.fromJson(result['credential']);
|
||||||
result['code'] != null ? OathCode.fromJson(result['code']) : null);
|
final newCode =
|
||||||
refresh();
|
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;
|
return pair.credential;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user