feat(api): add custom redirect back

This commit is contained in:
Mrugesh Mohapatra
2019-10-21 17:03:00 +05:30
committed by mrugesh
parent 3823ed19bc
commit aa62fdbfe9
9 changed files with 32 additions and 8 deletions

View File

@ -54,8 +54,19 @@ module.exports = function enableAuthentication(app) {
} else {
api.get(
'/signin',
(req, res, next) => {
if (req && req.query && req.query.returnTo) {
req.query.returnTo = `${homeLocation}/${req.query.returnTo}`;
}
return next();
},
ifUserRedirect,
passport.authenticate('auth0-login', {})
(req, res, next) => {
const state = req.query.returnTo
? Buffer.from(req.query.returnTo).toString('base64')
: null;
return passport.authenticate('auth0-login', { state })(req, res, next);
}
);
api.get(