Browse Source
Feat: Return client id of newly created client (#2190)
return client id of newly created client
pull/2195/head
Bernd Storath
3 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
6 additions and
3 deletions
-
src/server/api/client/index.post.ts
-
src/server/database/repositories/client/service.ts
|
|
@ -9,8 +9,10 @@ export default definePermissionEventHandler( |
|
|
|
validateZod(ClientCreateSchema, event) |
|
|
|
); |
|
|
|
|
|
|
|
await Database.clients.create({ name, expiresAt }); |
|
|
|
const result = await Database.clients.create({ name, expiresAt }); |
|
|
|
await WireGuard.saveConfig(); |
|
|
|
return { success: true }; |
|
|
|
|
|
|
|
const clientId = result[0]!.clientId; |
|
|
|
return { success: true, clientId }; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
@ -132,7 +132,7 @@ export class ClientService { |
|
|
|
const ipv6Cidr = parseCidr(clientInterface.ipv6Cidr); |
|
|
|
const ipv6Address = nextIP(6, ipv6Cidr, clients); |
|
|
|
|
|
|
|
await tx |
|
|
|
return await tx |
|
|
|
.insert(client) |
|
|
|
.values({ |
|
|
|
name, |
|
|
@ -150,6 +150,7 @@ export class ClientService { |
|
|
|
serverAllowedIps: [], |
|
|
|
enabled: true, |
|
|
|
}) |
|
|
|
.returning({ clientId: client.id }) |
|
|
|
.execute(); |
|
|
|
}); |
|
|
|
} |
|
|
|