|
@ -79,27 +79,21 @@ class CoreNodeService extends SiteService { |
|
|
router.get( |
|
|
router.get( |
|
|
coreAuthCallbackUri, |
|
|
coreAuthCallbackUri, |
|
|
(req, res, next) => { |
|
|
(req, res, next) => { |
|
|
this.log.debug('Core auth callback', { |
|
|
this.log.debug('Core auth callback', { strategy: coreAuthStrategyName }); |
|
|
strategy: coreAuthStrategyName, |
|
|
|
|
|
body: req.body, |
|
|
|
|
|
params: req.params, |
|
|
|
|
|
query: req.query, |
|
|
|
|
|
}); |
|
|
|
|
|
return next(); |
|
|
return next(); |
|
|
}, |
|
|
}, |
|
|
passport.authenticate(coreAuthStrategyName, { failureRedirect: '/' }), |
|
|
passport.authenticate(coreAuthStrategyName, { failureRedirect: '/' }), |
|
|
async (req, res) => { |
|
|
async (req, res, next) => { |
|
|
this.log.info('tagging session as Core', { coreId: core._id }); |
|
|
|
|
|
req.session.userType = 'Core'; |
|
|
req.session.userType = 'Core'; |
|
|
req.session.coreId = core._id; |
|
|
req.session.coreId = core._id; |
|
|
|
|
|
req.login(req.user, (error) => { |
|
|
// req.login(user, (error) => {
|
|
|
if (error) { |
|
|
// if (error) {
|
|
|
return next(error); |
|
|
// return next(error);
|
|
|
} |
|
|
// }
|
|
|
req.session.userType = 'Core'; |
|
|
// return res.redirect('/');
|
|
|
req.session.coreId = core._id; |
|
|
// });
|
|
|
return res.redirect('/'); |
|
|
return res.redirect('/'); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
); |
|
|
); |
|
|
}); |
|
|
}); |
|
@ -125,12 +119,6 @@ class CoreNodeService extends SiteService { |
|
|
}, |
|
|
}, |
|
|
async (accessToken, refreshToken, params, profile, cb) => { |
|
|
async (accessToken, refreshToken, params, profile, cb) => { |
|
|
const NOW = new Date(); |
|
|
const NOW = new Date(); |
|
|
this.log.info('Core login', { |
|
|
|
|
|
accessToken, |
|
|
|
|
|
refreshToken, |
|
|
|
|
|
params, |
|
|
|
|
|
profile, |
|
|
|
|
|
}); |
|
|
|
|
|
try { |
|
|
try { |
|
|
const coreUserId = mongoose.Types.ObjectId(params.coreUserId); |
|
|
const coreUserId = mongoose.Types.ObjectId(params.coreUserId); |
|
|
const user = await CoreUser.findOneAndUpdate( |
|
|
const user = await CoreUser.findOneAndUpdate( |
|
@ -183,12 +171,6 @@ class CoreNodeService extends SiteService { |
|
|
}, |
|
|
}, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// const old = coreAuthStrategy._loadUserProfile;
|
|
|
|
|
|
coreAuthStrategy._loadUserProfile = async (accessToken, done) => { |
|
|
|
|
|
this.log.info('loadUserProfile', { accessToken }); |
|
|
|
|
|
return done(null); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.log.info('registering Core auth strategy', { |
|
|
this.log.info('registering Core auth strategy', { |
|
|
name: coreAuthStrategyName, |
|
|
name: coreAuthStrategyName, |
|
|
host: core.address.host, |
|
|
host: core.address.host, |
|
|