mirror of
https://github.com/gurucomputing/headscale-ui.git
synced 2026-07-21 18:41:26 +00:00
basic preauth keys
This commit is contained in:
parent
209f1ece93
commit
9e650cd8bc
5 changed files with 11 additions and 6 deletions
|
|
@ -203,6 +203,7 @@
|
|||
|
||||
await headscalePreAuthKeyResponse.json().then((data) => {
|
||||
headscalePreAuthKey = data.preAuthKeys;
|
||||
console.log(headscalePreAuthKey);
|
||||
});
|
||||
return headscalePreAuthKey;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ export class PreAuthKey {
|
|||
public expiration: string = '';
|
||||
public reusable: boolean = false;
|
||||
public ephemeral: boolean = false;
|
||||
public used: boolean = false;
|
||||
|
||||
public constructor(init?: Partial<Device>) {
|
||||
Object.assign(this, init);
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@
|
|||
export let user = new User();
|
||||
let keyList = [new PreAuthKey()];
|
||||
|
||||
function testExpiry(keyExpiry: string): string {
|
||||
if((new Date(keyExpiry)).getTime() > (new Date()).getTime()) {
|
||||
return "text-success"
|
||||
// If the key hasn't expired or key hasn't been used, flag as green, otherwise flag as red
|
||||
function testExpiry(keyExpiry: string, keyUsed: boolean): string {
|
||||
if (new Date(keyExpiry).getTime() > new Date().getTime()) {
|
||||
if (!keyUsed) {
|
||||
return 'text-success';
|
||||
}
|
||||
}
|
||||
return "text-error"
|
||||
return 'text-error';
|
||||
}
|
||||
|
||||
function getPreauthKeysAction() {
|
||||
|
|
@ -36,7 +39,7 @@
|
|||
<td
|
||||
><ul class="list-disc list-inside">
|
||||
{#each keyList as key}
|
||||
<li><span class="{testExpiry(key.expiration)}">{key.key} </span></li>
|
||||
<li><span class="{testExpiry(key.expiration, key.used)}">{key.key} </span></li>
|
||||
{/each}
|
||||
</ul></td
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<!-- typescript -->
|
||||
<script lang="ts">
|
||||
import CreateUser from '$lib/index/UserCard/CreateUser.svelte';
|
||||
import CreateUser from '$lib/index/CreateUser.svelte';
|
||||
import UserCard from '$lib/index/UserCard.svelte';
|
||||
import { headscaleUserStore, apiTestStore } from '$lib/common/stores';
|
||||
import { onMount } from 'svelte';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue