Polarcraft/web/server/api/auth/getusers.js

14 lines
365 B
JavaScript
Raw Normal View History

2023-05-27 12:02:33 +02:00
export default defineEventHandler(async (event) => {
const user = await getAuth(event)
if (!user.role.moderator) return createError({ statusCode: 403, statusMessage: 'Gebruiker heeft geen toegang tot alle gebruikers' })
const usersColl = db.collection('users');
const cursor = usersColl.find()
const users = await cursor.toArray()
return users
});