Select key "push key" by default for new keys
This commit is contained in:
parent
8ce3805f4e
commit
7c5251fb99
@ -191,7 +191,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
TextButton(
|
||||
onPressed: authentikApiState.start,
|
||||
onPressed: () => authentikApiState.start(key),
|
||||
child: Text("Oauth2 Login"),
|
||||
),
|
||||
Text('Current output:'),
|
||||
@ -294,13 +294,15 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
case AuthentikUserSettingsChangeDialogStatus.userSettingsObtained:
|
||||
title = Text("User Settings Obtained");
|
||||
children = [Text("You can now edit your user settings.")];
|
||||
for (var k in authentikApiState.allKeys) {
|
||||
children.add(KeepOrDeleteKey(sshKey: k, isOurKey: k == key));
|
||||
}
|
||||
|
||||
if (!authentikApiState.allKeys.contains(key)) {
|
||||
// If the key is not already in the list, add it
|
||||
children.add(KeepOrDeleteKey(sshKey: key, isOurKey: true));
|
||||
|
||||
for (var k in authentikApiState.allKeys) {
|
||||
if (k == key) {
|
||||
// Skip our key, since the widget is on top already
|
||||
continue;
|
||||
}
|
||||
children.add(KeepOrDeleteKey(sshKey: k));
|
||||
}
|
||||
|
||||
actions.add(
|
||||
@ -424,7 +426,7 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
||||
return await grant.handleAuthorizationResponse(queryParameters);
|
||||
}
|
||||
|
||||
Future<void> start() async {
|
||||
Future<void> start(String currentKey) async {
|
||||
// Reset the state to be sure
|
||||
oauthClient = null;
|
||||
sessionCookie = null;
|
||||
@ -468,6 +470,12 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
||||
.split('\n')
|
||||
.where((key) => key.isNotEmpty)
|
||||
.toList();
|
||||
|
||||
_keysToKeep = _allKeys.toList();
|
||||
if (!_keysToKeep.contains(currentKey)) {
|
||||
// If the current key is not in the list of keys to keep, add it
|
||||
_keysToKeep.add(currentKey);
|
||||
}
|
||||
} else {
|
||||
throw Exception(
|
||||
"Expected 'attributes.sshPublicKeys' in user settings, but got: $userSettings",
|
||||
|
Loading…
x
Reference in New Issue
Block a user