fix: handle email verification exceptions (#1227)

This commit is contained in:
NGPixel 2019-11-23 15:06:34 -05:00
parent 49819b41db
commit 3d6b04f75d

View File

@ -122,12 +122,16 @@ router.get('/register', async (req, res, next) => {
* Verify * Verify
*/ */
router.get('/verify/:token', bruteforce.prevent, async (req, res, next) => { router.get('/verify/:token', bruteforce.prevent, async (req, res, next) => {
const usr = await WIKI.models.userKeys.validateToken({ kind: 'verify', token: req.params.token }) try {
await WIKI.models.users.query().patch({ isVerified: true }).where('id', usr.id) const usr = await WIKI.models.userKeys.validateToken({ kind: 'verify', token: req.params.token })
const result = await WIKI.models.users.refreshToken(usr) await WIKI.models.users.query().patch({ isVerified: true }).where('id', usr.id)
req.brute.reset() const result = await WIKI.models.users.refreshToken(usr)
res.cookie('jwt', result.token, { expires: moment().add(1, 'years').toDate() }) req.brute.reset()
res.redirect('/') res.cookie('jwt', result.token, { expires: moment().add(1, 'years').toDate() })
res.redirect('/')
} catch (err) {
next(err)
}
}) })
/** /**