check if invite is spent
This commit is contained in:
parent
c8ddd96743
commit
e48def3661
3 changed files with 20 additions and 17 deletions
|
|
@ -54,13 +54,7 @@ router.post('/invited-npub', async (req, res) => {
|
|||
return res.status(404).render('error', { message: 'Invite not found' });
|
||||
}
|
||||
|
||||
const isInviteSpent = await InvitedNpub.findOne({
|
||||
where: {
|
||||
app_invite_uuid: inviteUuid
|
||||
}
|
||||
})
|
||||
|
||||
if (isInviteSpent) {
|
||||
if (appInviteServices.isAppInviteSpent(inviteUuid)) {
|
||||
return res.status(410).json({ error: 'Invite has already been used.' });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,15 +20,9 @@ router.get('/invite/:inviteUuid', async (req, res) => {
|
|||
return res.status(404).render('error', { message: 'Invite not found' });
|
||||
}
|
||||
|
||||
const invite = appInviteServices.getInvite(inviteUuid);
|
||||
const invite = await appInviteServices.getAppInvite(inviteUuid);
|
||||
|
||||
const isInviteSpent = await InvitedNpub.findOne({
|
||||
where: {
|
||||
app_invite_uuid: inviteUuid
|
||||
}
|
||||
})
|
||||
|
||||
if (isInviteSpent) {
|
||||
if (await appInviteServices.isAppInviteSpent(inviteUuid)) {
|
||||
return res.render('invite_spent', { invite })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue