mirror of
https://github.com/gurucomputing/headscale-ui.git
synced 2026-01-23 02:34:43 +00:00
check api key list
This commit is contained in:
parent
987cbdcda1
commit
ac15a15caf
2 changed files with 10 additions and 2 deletions
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
export async function rotateAPIKey() {
|
||||
for (const key of appSettings.apiKeyList) {
|
||||
|
||||
// select the current key being used in the app settings
|
||||
if (persistentAppSettings.headscaleAPIKey.startsWith(key.prefix)) {
|
||||
let currentKey = key;
|
||||
|
|
@ -59,14 +60,18 @@
|
|||
|
||||
// create a new API key with the new expiration
|
||||
let apiKey = await createNewAPIKey(newExpiration);
|
||||
// The above should always return a value
|
||||
|
||||
// The above should always return a value, let's check that
|
||||
if (apiKey == undefined) {
|
||||
throw new Error('expecting API key string, string was undefined');
|
||||
}
|
||||
|
||||
// Set the new key as the current key in the persistent settings
|
||||
persistentAppSettings.headscaleAPIKey = apiKey;
|
||||
|
||||
// Expire the previously current key
|
||||
await expireAPIKey(currentKey.prefix);
|
||||
|
||||
// Get keys again to make sure it all worked
|
||||
await getAPIKeys();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
function rotateAPIKeyClick() {
|
||||
rotateButtonDisabled = true;
|
||||
rotateAPIKey().then(() => {rotateButtonDisabled = false});
|
||||
rotateAPIKey().then(() => {
|
||||
rotateButtonDisabled = false;
|
||||
console.log(appSettings.apiKeyList);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue