Browse Source

fix(ui):Error pops up when enabling disabled client (#2594)

* fix(ui):Error pops up when enabling disabled client

Action is prevented and a clear message is displayed in Web UI

* fix formatting

* fix type issue

* fix formatting

---------

Co-authored-by: Bernd Storath <[email protected]>
pull/2601/head
Felipe Cordova Huenupil 1 month ago
committed by GitHub
parent
commit
05c655ede9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 13
      src/server/api/client/[clientId]/enable.post.ts

13
src/server/api/client/[clientId]/enable.post.ts

@ -12,6 +12,19 @@ export default definePermissionEventHandler(
const client = await Database.clients.get(clientId);
checkPermissions(client);
if (
client &&
client.expiresAt !== null &&
new Date() > new Date(client.expiresAt)
) {
throw createError({
statusCode: 422,
statusMessage:
'Client is expired. Please update the expiration date first.',
message: 'Client is expired. Please update the expiration date first.',
});
}
await Database.clients.toggle(clientId, true);
await WireGuard.saveConfig();
return { success: true };

Loading…
Cancel
Save