Browse Source

fix regressions

fix missing expire date in client create dialog
fix wrong type rules
fix wrong api endpoint
pull/1354/head
Bernd Storath 8 months ago
parent
commit
36cb934527
  1. 18
      src/components/Clients/CreateDialog.vue
  2. 7
      src/server/utils/types.ts
  3. 4
      src/stores/modal.ts
  4. 2
      src/utils/api.ts

18
src/components/Clients/CreateDialog.vue

@ -71,6 +71,23 @@
/>
</p>
</div>
<div v-show="globalStore.enableExpireTime" class="mt-2">
<p class="text-sm text-gray-500">
<label
class="block text-gray-900 dark:text-neutral-200 text-sm font-bold mb-2"
for="expireDate"
>
{{ $t('ExpireDate') }}
</label>
<input
v-model.trim="modalStore.clientExpireDate"
class="rounded p-2 border-2 dark:bg-neutral-700 dark:text-neutral-200 border-gray-100 dark:border-neutral-600 focus:border-gray-200 focus:dark:border-neutral-500 dark:placeholder:text-neutral-400 outline-none w-full"
type="date"
:placeholder="$t('ExpireDate')"
name="expireDate"
/>
</p>
</div>
</div>
</div>
</div>
@ -110,4 +127,5 @@
<script setup lang="ts">
const modalStore = useModalStore();
const globalStore = useGlobalStore();
</script>

7
src/server/utils/types.ts

@ -30,14 +30,13 @@ const password = z
.string({ message: 'Password must be a valid string' })
.pipe(safeStringRefine);
const remember = z
.boolean({ message: 'Remember must be a valid boolean' })
.optional();
const remember = z.boolean({ message: 'Remember must be a valid boolean' });
const expireDate = z
.string({ message: 'expiredDate must be a valid string' })
.min(1, 'expiredDate must be at least 1 Character')
.pipe(safeStringRefine);
.pipe(safeStringRefine)
.nullable();
export const clientIdType = z.object(
{

4
src/stores/modal.ts

@ -5,12 +5,12 @@ export const useModalStore = defineStore('Modal', () => {
const clientDelete = ref<null | WGClient>(null);
const clientCreate = ref<null | boolean>(null);
const clientCreateName = ref<string>('');
const clientExpireDate = ref<string | null>(null);
const clientExpireDate = ref<string>('');
const qrcode = ref<null | string>(null);
function createClient() {
const name = clientCreateName.value;
const expireDate = clientExpireDate.value;
const expireDate = clientExpireDate.value || null;
if (!name) return;
api

2
src/utils/api.ts

@ -93,7 +93,7 @@ class API {
}
async showOneTimeLink({ clientId }: { clientId: string }) {
return $fetch(`/api/wireguard/${clientId}/:clientId/generateOneTimeLink`, {
return $fetch(`/api/wireguard/client/${clientId}/generateOneTimeLink`, {
method: 'post',
});
}

Loading…
Cancel
Save