Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function(cb) {
// TODO: Work out in what cases we may actually want to sign out the user
return cb();
if (!req.user) return cb();
keystone.session.signout(req, res, function() {
return cb();
});
}
function(cb) {
// TODO: Work out in what cases we may actually want to sign out the user
return cb();
if (!req.user) return cb();
keystone.session.signout(req, res, function() {
return cb();
});
}
keystone.init(config.options);
keystone.import('models');
keystone.set('locals', config.locals);
keystone.set('routes', require('./routes'));
keystone.set('nav', config.nav);
keystone.initDatabaseConfig();
keystone.initExpressSession();
app.use(compression());
app.use('/keystone', keystone.Admin.Server.createStaticRouter(keystone));
app.use(express.static('public'));
app.use(keystone.get('session options').cookieParser);
app.use(keystone.expressSession);
app.use(keystone.session.persist);
app.use(require('connect-flash')());
app.use(morgan('tiny'));
app.use('/keystone', keystone.Admin.Server.createDynamicRouter(keystone));
app.use(function (req, res) {
res.redirect('/keystone');
});
keystone.openDatabaseConnection(function () {
var server = app.listen(process.env.PORT || 3001, function () {
console.log('-------------------------------');
console.log('Express server ready on port %d', server.address().port);
console.log('-------------------------------');
});
});
console.log('------------------------------------------------------------');
var onSuccess = function(user) {
console.log('[auth.confirm] - Successfully signed in.');
console.log('------------------------------------------------------------');
return res.redirect('/settings');
}
var onFail = function(err) {
console.log('[auth.confirm] - Failed signing in.', err);
console.log('------------------------------------------------------------');
req.flash('error', 'Sorry, there was an issue signing you in, please try again.');
return res.redirect('/login');
}
keystone.session.signin(String(locals.existingUser._id), req, res, onSuccess, onFail);
}
console.log('------------------------------------------------------------');
return callback();
}
var onFail = function(err) {
console.log("[services.twitter] - Failed signing in.");
console.log('------------------------------------------------------------');
return callback(true);
}
keystone.session.signin( String(data.sydjsUser._id), req, res, onSuccess, onFail);
}
date: new Date().getTime(),
userId: user.id
});
}
var onFail = function(err) {
console.log('[api.app.service] - Failed signing in.', err);
console.log('------------------------------------------------------------');
return res.apiResponse({
success: false,
session: false,
message: (err && err.message ? err.message : false) || 'Sorry, there was an issue signing you in, please try again.'
});
}
keystone.session.signin(String(locals.existingUser._id), req, res, onSuccess, onFail);
}
console.log('------------------------------------------------------------');
var onSuccess = function(user) {
console.log('[auth.confirm] - Successfully signed in.');
console.log('------------------------------------------------------------');
return res.redirect(req.cookies.target || '/me');
}
var onFail = function(err) {
console.log('[auth.confirm] - Failed signing in.', err);
console.log('------------------------------------------------------------');
req.flash('error', 'Sorry, there was an issue signing you in, please try again.');
return res.redirect('/signin');
}
keystone.session.signin(String(locals.existingUser._id), req, res, onSuccess, onFail);
}
], function(err){
if (err) return next();
var onSuccess = function() {
return res.redirect('/me');
}
var onFail = function(e) {
req.flash('error', 'There was a problem signing you in, please try again.');
return next();
}
keystone.session.signin({ email: req.body.join_email, password: req.body.join_password }, req, res, onSuccess, onFail);
});
app.post(base + '/user/logout', (req, res) => {
keystone.session.signout(req, res, function(err) {
uidCookie.remove(req, res);
responseHandler(res, err, {});
});
});
var onSuccess = function() {
if (locals.journeyOrigin) {
res.redirect(locals.journeyOrigin + (locals.journeyOrigin.match('/topic/') ? '?performFunction=focusOnCommentField' : ''));
req.session.journeyOrigin = null;
} else {
res.redirect('/settings');
}
}
var onFail = function() {
req.flash('error', 'Your username or password were incorrect, please try again.');
return next();
}
keystone.session.signin({ email: req.body.signin_email, password: req.body.signin_password }, req, res, onSuccess, onFail);
});