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