diff --git a/src/lib/common/apiFunctions.svelte b/src/lib/common/apiFunctions.svelte index 206ac73..0a896ba 100644 --- a/src/lib/common/apiFunctions.svelte +++ b/src/lib/common/apiFunctions.svelte @@ -329,7 +329,7 @@ return apiKeys; } - export async function getPreauthKeys(userId: string): Promise { + export async function getPreauthKeys(userName: string): Promise { // variables in local storage let headscaleURL = localStorage.getItem('headscaleURL') || ''; let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; @@ -341,7 +341,7 @@ let headscalePreAuthKey = [new PreAuthKey()]; let headscalePreAuthKeyResponse: Response = new Response(); - await fetch(headscaleURL + endpointURL + '?user=' + userId, { + await fetch(headscaleURL + endpointURL + '?user=' + userName, { method: 'GET', headers: { Accept: 'application/json', @@ -367,7 +367,7 @@ return headscalePreAuthKey; } - export async function newPreAuthKey(userId: string, expiry: string, reusable: boolean, ephemeral: boolean): Promise { + export async function newPreAuthKey(userName: string, expiry: string, reusable: boolean, ephemeral: boolean): Promise { // variables in local storage let headscaleURL = localStorage.getItem('headscaleURL') || ''; let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; @@ -381,7 +381,7 @@ Authorization: `Bearer ${headscaleAPIKey}` }, body: JSON.stringify({ - user: userId, + user: userName, expiration: expiry, reusable: reusable, ephemeral: ephemeral @@ -401,7 +401,7 @@ }); } - export async function removePreAuthKey(userId: string, preAuthKey: string): Promise { + export async function removePreAuthKey(userName: string, preAuthKey: string): Promise { // variables in local storage let headscaleURL = localStorage.getItem('headscaleURL') || ''; let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; @@ -416,7 +416,7 @@ Authorization: `Bearer ${headscaleAPIKey}` }, body: JSON.stringify({ - user: userId, + user: userName, key: preAuthKey }) }) diff --git a/src/lib/users/UserCard/PreAuthKeys.svelte b/src/lib/users/UserCard/PreAuthKeys.svelte index 086ccb9..7c5ea4c 100644 --- a/src/lib/users/UserCard/PreAuthKeys.svelte +++ b/src/lib/users/UserCard/PreAuthKeys.svelte @@ -10,8 +10,8 @@ export let keyList = [new PreAuthKey]; let newPreAuthKeyShow = false; - function expirePreAuthKeyAction(userId: string, preAuthKey: string) { - removePreAuthKey(userId, preAuthKey) + function expirePreAuthKeyAction(userName: string, preAuthKey: string) { + removePreAuthKey(userName, preAuthKey) .then(() => { getPreauthKeysAction(); }) @@ -107,7 +107,7 @@ {#if new Date(key.expiration).getTime() > new Date().getTime() && (!key.used || key.reusable)} - { newPreAuthKeyShow = false; getPreauthKeysAction(); @@ -26,7 +26,7 @@ } function getPreauthKeysAction() { - getPreauthKeys(user.id) + getPreauthKeys(user.name) .then((keys) => { keyList = keys; })