exports.setProviderConfig = function (req, res) { var config = utils.validateAgainstSchema(req.body, common.extensions.provider[req.project.provider.id].config) _.extend(req.project.provider.config, config) req.project.markModified('provider.config') req.project.save(function (err, project) { if (err) return res.send(500, {error: 'Failed to save runner config'}) res.send(project.provider.config) }) }
server.post('/api/session', function (req, res) { //Verify that the request body has the proper format for a user post. result = validator.validateAgainstSchema(req, res, 'sessionPost'); if(result === true) { //Check to see if the email / password combo can be found. //Build the query to look up the user by their email address and password hash. var query = User.findOne({ email: req.body.email }, function (err, user) { if(user === null) { res.send(409, { 'code': 'InvalidArgument', 'message': 'The user account was not found.' }); } else { //Compare the password hash that we have with the password hash of the submitted password. if(passwordHash.verify(req.body.password, user.password)) { //The login is correct. Generate a session token and save it in the session table. async.waterfall([ function (callback) { log.info('Generating crypto token'); crypto.randomBytes(48, function(ex, buf) { callback(null, buf.toString('hex')); }); }, function (token, callback) { var sessionData = { user: user._id, application: req.body.application, token: token }; var newSession = new Session(sessionData); newSession.save(function (err) { callback(null, sessionData); }); } ], function (err, result) { res.send(result); } ); } else { res.send(409, { 'code': 'InvalidArgument', 'message': 'The user account was not found.' }); } } } ); } });