From 84ee8c35f0715b3154bccf59cc6a4daeba92bd66 Mon Sep 17 00:00:00 2001
From: Bernd Storath <999999bst@gmail.com>
Date: Wed, 5 Mar 2025 15:38:09 +0100
Subject: [PATCH] fix labels, date field, enable
---
.github/ISSUE_TEMPLATE/01-bug-report.yml | 2 -
src/app/components/Form/DateField.vue | 37 ++++++++++++++-----
.../api/client/[clientId]/enable.post.ts | 2 +-
.../database/repositories/client/service.ts | 11 +-----
.../database/repositories/client/types.ts | 1 +
src/server/utils/config.ts | 2 -
6 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/01-bug-report.yml b/.github/ISSUE_TEMPLATE/01-bug-report.yml
index 517d812c..390ec35b 100644
--- a/.github/ISSUE_TEMPLATE/01-bug-report.yml
+++ b/.github/ISSUE_TEMPLATE/01-bug-report.yml
@@ -2,8 +2,6 @@
name: 🐛 Bug Report
description: Create a report to help us improve
title: "[Bug]: "
-labels:
- - "type: bug"
type: Bug
body:
diff --git a/src/app/components/Form/DateField.vue b/src/app/components/Form/DateField.vue
index a1474984..e82043f4 100644
--- a/src/app/components/Form/DateField.vue
+++ b/src/app/components/Form/DateField.vue
@@ -7,19 +7,38 @@
-
+
diff --git a/src/server/api/client/[clientId]/enable.post.ts b/src/server/api/client/[clientId]/enable.post.ts
index 0338045f..406c33ac 100644
--- a/src/server/api/client/[clientId]/enable.post.ts
+++ b/src/server/api/client/[clientId]/enable.post.ts
@@ -12,7 +12,7 @@ export default definePermissionEventHandler(
const client = await Database.clients.get(clientId);
checkPermissions(client);
- await Database.clients.toggle(clientId, false);
+ await Database.clients.toggle(clientId, true);
await WireGuard.saveConfig();
return { success: true };
}
diff --git a/src/server/database/repositories/client/service.ts b/src/server/database/repositories/client/service.ts
index e13509e4..3cc5a2b9 100644
--- a/src/server/database/repositories/client/service.ts
+++ b/src/server/database/repositories/client/service.ts
@@ -75,15 +75,6 @@ export class ClientService {
const publicKey = await wg.getPublicKey(privateKey);
const preSharedKey = await wg.generatePreSharedKey();
- let parsedExpiresAt = expiresAt;
- if (parsedExpiresAt) {
- const expiresAtDate = new Date(parsedExpiresAt);
- expiresAtDate.setHours(23);
- expiresAtDate.setMinutes(59);
- expiresAtDate.setSeconds(59);
- parsedExpiresAt = expiresAtDate.toISOString();
- }
-
return this.#db.transaction(async (tx) => {
const clients = await tx.query.client.findMany().execute();
const clientInterface = await tx.query.wgInterface
@@ -117,7 +108,7 @@ export class ClientService {
name,
// TODO: properly assign user id
userId: 1,
- expiresAt: parsedExpiresAt,
+ expiresAt,
privateKey,
publicKey,
preSharedKey,
diff --git a/src/server/database/repositories/client/types.ts b/src/server/database/repositories/client/types.ts
index 09bbce13..3be4b572 100644
--- a/src/server/database/repositories/client/types.ts
+++ b/src/server/database/repositories/client/types.ts
@@ -22,6 +22,7 @@ const name = z
.min(1, t('zod.client.name'))
.pipe(safeStringRefine);
+// TODO?: validate iso string
const expiresAt = z
.string({ message: t('zod.client.expiresAt') })
.min(1, t('zod.client.expiresAt'))
diff --git a/src/server/utils/config.ts b/src/server/utils/config.ts
index 71805e2e..8b0f8c09 100644
--- a/src/server/utils/config.ts
+++ b/src/server/utils/config.ts
@@ -16,5 +16,3 @@ export const WG_ENV = {
/** UI is hosted on HTTP instead of HTTPS */
INSECURE: process.env.INSECURE === 'true',
};
-
-console.log(WG_ENV);