refactor inviteExists
This commit is contained in:
parent
b226fc57a8
commit
36cff3a6bd
1 changed files with 9 additions and 2 deletions
|
|
@ -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' });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue