Change the email returned by Headscale API to username

Change the email returned by Headscale API to username for PreAuthKey frontend.
This commit is contained in:
bitbronze 2025-03-18 16:39:19 +03:00 committed by GitHub
parent 23fd2bbda2
commit 63d6353d38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,10 +26,17 @@ export async function loader({ request }: LoaderFunctionArgs) {
const qp = new URLSearchParams(); const qp = new URLSearchParams();
qp.set('user', user.name); qp.set('user', user.name);
return pull<{ preAuthKeys: PreAuthKey[] }>( var result = pull<{ preAuthKeys: PreAuthKey[] }>(
`v1/preauthkey?${qp.toString()}`, `v1/preauthkey?${qp.toString()}`,
session.get('hsApiKey')!, session.get('hsApiKey')!,
); );
// Change the email returned by Headscale API to username
result.forEach((preauthkey_item, index) => {
preauthkey_item.user = user;
});
return result;
}), }),
); );