Files
veridian/server/api/invite/[token].get.ts
T
2026-10-08 13:50:44 -05:00

23 lines
632 B
TypeScript

/**
* Tells the register page whether an invite link still works and who it is
* from. Public on purpose, the person opening the link has no account yet.
*/
export default defineEventHandler(async (event) => {
const invite = await findUsableInvite(getRouterParam(event, 'token')!);
if (!invite) {
return { valid: false as const };
}
return {
valid: true as const,
expiresAt: invite.expiresAt,
singleUse: invite.maxUses === 1,
inviter: {
id: invite.inviterId,
name: invite.inviterName,
image: invite.inviterImage,
},
};
});