From f59111025b762d8067015e6d14d6295f9cde36b5 Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Mon, 11 Aug 2025 14:35:30 +0800 Subject: [PATCH] Added client profile update --- src/dashboard.py | 8 +++ src/modules/DashboardClients.py | 16 +++++ src/modules/DashboardConfig.py | 3 + src/static/app/package.json | 1 + .../clientSettingComponents/oidcSettings.vue | 13 ++-- .../clientComponents/clientSettings.vue | 26 +++++++- .../clientComponents/clientViewer.vue | 64 +++++++++++++++---- src/static/app/src/views/settings.vue | 2 - 8 files changed, 109 insertions(+), 24 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index 838b0b9..06e4c70 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -1325,6 +1325,14 @@ def API_Clients_GeneratePasswordResetLink(): return ResponseObject(data=token) return ResponseObject(False, "Failed to generate link") +@app.post(f'{APP_PREFIX}/api/clients/updateProfileName') +def API_Clients_UpdateProfile(): + data = request.get_json() + clientId = data.get("ClientID") + if not clientId: + return ResponseObject(False, "Please provide ClientID") + value = data.get('Name') + return ResponseObject(status=DashboardClients.UpdateClientProfile(clientId, value)) ''' Index Page ''' diff --git a/src/modules/DashboardClients.py b/src/modules/DashboardClients.py index 503e2d5..bb1ab06 100644 --- a/src/modules/DashboardClients.py +++ b/src/modules/DashboardClients.py @@ -331,6 +331,22 @@ class DashboardClients: return False, "Signed up failed." return True, None + def UpdateClientProfile(self, ClientID, Name): + try: + with self.engine.begin() as conn: + conn.execute( + self.dashboardClientsInfoTable.update().values({ + "Name": Name + }).where( + self.dashboardClientsInfoTable.c.ClientID == ClientID + ) + ) + self.logger.log(Message=f"User {ClientID} updated name to {Name}") + except Exception as e: + self.logger.log(Status="false", Message=f"User {ClientID} updated name to {Name} failed") + return False + return True + ''' For WGDashboard Admin to Manage Clients ''' diff --git a/src/modules/DashboardConfig.py b/src/modules/DashboardConfig.py index eb4c174..798638d 100644 --- a/src/modules/DashboardConfig.py +++ b/src/modules/DashboardConfig.py @@ -80,6 +80,9 @@ class DashboardConfig: "admin_enable": "false", "client_enable": "false" }, + "Clients": { + "allow_local_sign_up": "true" + }, "WireGuardConfiguration": { "autostart": "" } diff --git a/src/static/app/package.json b/src/static/app/package.json index c91f53a..28d2ae1 100644 --- a/src/static/app/package.json +++ b/src/static/app/package.json @@ -3,6 +3,7 @@ "version": "4.3", "private": true, "type": "module", + "module": "es2022", "scripts": { "dev": "vite", "build": "vite build", diff --git a/src/static/app/src/components/clientComponents/clientSettingComponents/oidcSettings.vue b/src/static/app/src/components/clientComponents/clientSettingComponents/oidcSettings.vue index a38b0f0..23f6687 100644 --- a/src/static/app/src/components/clientComponents/clientSettingComponents/oidcSettings.vue +++ b/src/static/app/src/components/clientComponents/clientSettingComponents/oidcSettings.vue @@ -1,28 +1,27 @@ diff --git a/src/static/app/src/components/clientComponents/clientSettings.vue b/src/static/app/src/components/clientComponents/clientSettings.vue index 645abb1..5e8d985 100644 --- a/src/static/app/src/components/clientComponents/clientSettings.vue +++ b/src/static/app/src/components/clientComponents/clientSettings.vue @@ -1,8 +1,14 @@