2b42b639ea
* feat: Add search client based on #1978 * moved the filtering to the DB level using zod and tidied up some imports. * minor fix * minor fix * fix typo --------- Co-authored-by: Bernd Storath <999999bst@gmail.com>
18 lines
435 B
TypeScript
18 lines
435 B
TypeScript
import { ClientQuerySchema } from '#db/repositories/client/types';
|
|
|
|
export default definePermissionEventHandler(
|
|
'clients',
|
|
'custom',
|
|
async ({ event, user }) => {
|
|
const { filter } = await getValidatedQuery(
|
|
event,
|
|
validateZod(ClientQuerySchema, event)
|
|
);
|
|
|
|
if (user.role === roles.ADMIN) {
|
|
return WireGuard.getAllClients(filter);
|
|
}
|
|
return WireGuard.getClientsForUser(user.id, filter);
|
|
}
|
|
);
|