function signinWithUser (user, req, res, onSuccess) {
	if (arguments.length < 4) {
		throw new Error('keystone.session.signinWithUser requires user, req and res objects, and an onSuccess callback.');
	}
	if (typeof user !== 'object') {
		throw new Error('keystone.session.signinWithUser requires user to be an object.');
	}
	if (typeof req !== 'object') {
		throw new Error('keystone.session.signinWithUser requires req to be an object.');
	}
	if (typeof res !== 'object') {
		throw new Error('keystone.session.signinWithUser requires res to be an object.');
	}
	if (typeof onSuccess !== 'function') {
		throw new Error('keystone.session.signinWithUser requires onSuccess to be a function.');
	}
	req.session.regenerate(function () {
		req.user = user;
		req.session.userId = user.id;
		// if the user has a password set, store a persistent cookie to resume sessions
		if (keystone.get('cookie signin') && user.password) {
			var userToken = user.id + ':' + hash(user.password);
			var cookieOpts = _.defaults({}, keystone.get('cookie signin options'), {
				signed: true,
				httpOnly: true,
				maxAge: 10 * 24 * 60 * 60 * 1000,
			});
			if (req.session.cookie) {
				req.session.cookie.maxAge = cookieOpts.maxAge;
			}
			res.cookie('keystone.uid', userToken, cookieOpts);
		}
		onSuccess(user);
	});
}
Signs in a user using user obejct

@param {Object} user - user object
@param {Object} req - express request object
@param {Object} res - express response object
@param {function()} onSuccess callback, is passed the User instance