Browse Source
fix(ui):Error pops up when enabling disabled client
Action is prevented and a clear message is displayed in Web UI
pull/2594/head
Felipe Cordova
3 months ago
No known key found for this signature in database
GPG Key ID: F9C05E11DA22D9FB
1 changed files with
8 additions and
0 deletions
-
src/server/api/client/[clientId]/enable.post.ts
|
|
|
@ -12,6 +12,14 @@ export default definePermissionEventHandler( |
|
|
|
const client = await Database.clients.get(clientId); |
|
|
|
checkPermissions(client); |
|
|
|
|
|
|
|
if (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 }; |
|
|
|
|