Feat: Return client id of newly created client (#2190)
return client id of newly created client
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user