refactor inviteExists

This commit is contained in:
counterweight 2025-02-09 23:47:34 +01:00
parent b226fc57a8
commit 36cff3a6bd
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -48,9 +48,16 @@ router.post('/invited-npub', async (req, res) => {
const inviteUuid = req.cookies.inviteUuid;
const npub = req.body.npub;
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
if (!invite) {
async function inviteExists(inviteUuid) {
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
if (invite) {
return true;
}
return false;
}
if (!inviteExists(inviteUuid)) {
return res.status(404).render('error', { message: 'Invite not found' });
}