mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-08 18:45:33 +08:00
Implement authentication, waitlist, and logging upgrades
This commit is contained in:
15
server/api/auth/invitations.get.ts
Normal file
15
server/api/auth/invitations.get.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { requireUserSession } from '../../utils/auth'
|
||||
import { InvitationCode } from '../../models/InvitationCode'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = await requireUserSession(event)
|
||||
const codes = await InvitationCode.find({ createdBy: user._id }).sort({ createdAt: -1 }).lean()
|
||||
return codes.map((code) => ({
|
||||
code: code.code,
|
||||
createdAt: code.createdAt,
|
||||
expiresAt: code.expiresAt,
|
||||
usedAt: code.usedAt,
|
||||
usedBy: code.usedBy ? String(code.usedBy) : null,
|
||||
}))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user