Browse Source
fix: loginRedirect doesn't work for non local strategies (#3222)
pull/3245/head
PaulD987
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
13 additions and
1 deletions
-
server/controllers/auth.js
|
@ -71,7 +71,19 @@ router.all('/login/:strategy/callback', async (req, res, next) => { |
|
|
strategy: req.params.strategy |
|
|
strategy: req.params.strategy |
|
|
}, { req, res }) |
|
|
}, { req, res }) |
|
|
res.cookie('jwt', authResult.jwt, { expires: moment().add(1, 'y').toDate() }) |
|
|
res.cookie('jwt', authResult.jwt, { expires: moment().add(1, 'y').toDate() }) |
|
|
res.redirect(authResult.redirect) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const loginRedirect = req.cookies['loginRedirect'] |
|
|
|
|
|
if (loginRedirect === '/' && authResult.redirect) { |
|
|
|
|
|
res.clearCookie('loginRedirect') |
|
|
|
|
|
res.redirect(authResult.redirect) |
|
|
|
|
|
} else if (loginRedirect) { |
|
|
|
|
|
res.clearCookie('loginRedirect') |
|
|
|
|
|
res.redirect(loginRedirect) |
|
|
|
|
|
} else if (authResult.redirect) { |
|
|
|
|
|
res.redirect(authResult.redirect) |
|
|
|
|
|
} else { |
|
|
|
|
|
res.redirect('/') |
|
|
|
|
|
} |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
next(err) |
|
|
next(err) |
|
|
} |
|
|
} |
|
|