prevent potential redirect loop with activation link

This commit is contained in:
Evert Prants 2017-10-14 23:35:22 +03:00
parent 1e027c4b88
commit b0a6856fbc
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -737,11 +737,14 @@ router.get('/logout', (req, res) => {
router.get('/activate/:token', wrap(async (req, res) => {
if (req.session.user) return res.redirect('/login')
let token = req.params.token
let success = await API.User.Login.activationToken(token)
if (!success) return formError(req, res, 'Unknown or invalid activation token')
if (!success) {
req.flash('message', {error: true, text: 'Invalid or expired activation token.'})
} else {
req.flash('message', {error: false, text: 'Your account has been activated! You may now log in.'})
}
res.redirect('/login')
}))