|
51 | 51 | filterUsers(); |
52 | 52 | } |
53 | 53 |
|
54 | | - export async function editUser(currentUsername: string, newUsername: string): Promise<any> { |
| 54 | + export async function editUser(currentUserId: string, newUsername: string): Promise<any> { |
55 | 55 | // variables in local storage |
56 | 56 | let headscaleURL = localStorage.getItem('headscaleURL') || ''; |
57 | 57 | let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; |
58 | 58 |
|
59 | 59 | // endpoint url for editing users |
60 | | - let endpointURL = '/api/v1/user/' + currentUsername + '/rename/' + newUsername; |
| 60 | + let endpointURL = '/api/v1/user/' + currentUserId + '/rename/' + newUsername; |
61 | 61 |
|
62 | 62 | await fetch(headscaleURL + endpointURL, { |
63 | 63 | method: 'POST', |
|
184 | 184 | }); |
185 | 185 | } |
186 | 186 |
|
187 | | - export async function removeUser(currentUsername: string): Promise<any> { |
| 187 | + export async function removeUser(currentUserId: string): Promise<any> { |
188 | 188 | // variables in local storage |
189 | 189 | let headscaleURL = localStorage.getItem('headscaleURL') || ''; |
190 | 190 | let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; |
191 | 191 |
|
192 | 192 | // endpoint url for editing users |
193 | | - let endpointURL = '/api/v1/user/' + currentUsername; |
| 193 | + let endpointURL = '/api/v1/user/' + currentUserId; |
194 | 194 |
|
195 | 195 | await fetch(headscaleURL + endpointURL, { |
196 | 196 | method: 'DELETE', |
|
329 | 329 | return apiKeys; |
330 | 330 | } |
331 | 331 |
|
332 | | - export async function getPreauthKeys(userName: string): Promise<PreAuthKey[]> { |
| 332 | + export async function getPreauthKeys(userId: string): Promise<PreAuthKey[]> { |
333 | 333 | // variables in local storage |
334 | 334 | let headscaleURL = localStorage.getItem('headscaleURL') || ''; |
335 | 335 | let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; |
|
341 | 341 | let headscalePreAuthKey = [new PreAuthKey()]; |
342 | 342 | let headscalePreAuthKeyResponse: Response = new Response(); |
343 | 343 |
|
344 | | - await fetch(headscaleURL + endpointURL + '?user=' + userName, { |
| 344 | + await fetch(headscaleURL + endpointURL + '?user=' + userId, { |
345 | 345 | method: 'GET', |
346 | 346 | headers: { |
347 | 347 | Accept: 'application/json', |
|
367 | 367 | return headscalePreAuthKey; |
368 | 368 | } |
369 | 369 |
|
370 | | - export async function newPreAuthKey(userName: string, expiry: string, reusable: boolean, ephemeral: boolean): Promise<any> { |
| 370 | + export async function newPreAuthKey(userId: string, expiry: string, reusable: boolean, ephemeral: boolean): Promise<any> { |
371 | 371 | // variables in local storage |
372 | 372 | let headscaleURL = localStorage.getItem('headscaleURL') || ''; |
373 | 373 | let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; |
|
381 | 381 | Authorization: `Bearer ${headscaleAPIKey}` |
382 | 382 | }, |
383 | 383 | body: JSON.stringify({ |
384 | | - user: userName, |
| 384 | + user: userId, |
385 | 385 | expiration: expiry, |
386 | 386 | reusable: reusable, |
387 | 387 | ephemeral: ephemeral |
|
401 | 401 | }); |
402 | 402 | } |
403 | 403 |
|
404 | | - export async function removePreAuthKey(userName: string, preAuthKey: string): Promise<any> { |
| 404 | + export async function removePreAuthKey(userId: string, preAuthKey: string): Promise<any> { |
405 | 405 | // variables in local storage |
406 | 406 | let headscaleURL = localStorage.getItem('headscaleURL') || ''; |
407 | 407 | let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; |
|
416 | 416 | Authorization: `Bearer ${headscaleAPIKey}` |
417 | 417 | }, |
418 | 418 | body: JSON.stringify({ |
419 | | - user: userName, |
| 419 | + user: userId, |
420 | 420 | key: preAuthKey |
421 | 421 | }) |
422 | 422 | }) |
|
434 | 434 | }); |
435 | 435 | } |
436 | 436 |
|
437 | | - export async function newDevice(key: string, userName: string): Promise<any> { |
| 437 | + export async function newDevice(key: string, userId: string): Promise<any> { |
438 | 438 |
|
439 | 439 | // variables in local storage |
440 | 440 | let headscaleURL = localStorage.getItem('headscaleURL') || ''; |
|
443 | 443 | // endpoint url for editing users |
444 | 444 | let endpointURL = `/api/v1/node/register`; |
445 | 445 |
|
446 | | - await fetch(headscaleURL + endpointURL + '?user=' + userName + '&key=' + key, { |
| 446 | + await fetch(headscaleURL + endpointURL + '?user=' + userId + '&key=' + key, { |
447 | 447 | method: 'POST', |
448 | 448 | headers: { |
449 | 449 | Accept: 'application/json', |
|
0 commit comments