mirror of https://github.com/wg-easy/wg-easy
1 changed files with 18 additions and 0 deletions
@ -0,0 +1,18 @@ |
|||||
|
import { ClientQuerySchema } from '#db/repositories/client/types'; |
||||
|
|
||||
|
export default definePermissionEventHandler( |
||||
|
'clients', |
||||
|
'custom', |
||||
|
async ({ event, user }) => { |
||||
|
const { filter } = await getValidatedQuery( |
||||
|
event, |
||||
|
validateZod(ClientQuerySchema, event) |
||||
|
); |
||||
|
|
||||
|
// Filter is used to search by name, IPv4, or IPv6
|
||||
|
if (user.role === roles.ADMIN) { |
||||
|
return WireGuard.getAllClients(filter); |
||||
|
} |
||||
|
return WireGuard.getClientsForUser(user.id, filter); |
||||
|
} |
||||
|
); |
||||
Loading…
Reference in new issue