3d-interface/posts/identification/index.js

33 lines
900 B
JavaScript
Raw Normal View History

2015-07-23 17:19:53 +02:00
var pg = require('pg');
var secret = require('../../private');
var db = require('../../controllers/prototype/dbrequests.js');
var Log = require('../../lib/NodeLog.js');
module.exports.index = function(req, res) {
2015-07-27 16:59:53 +02:00
var workerId = req.session.workerId || req.body.inputId;
db.checkUserName(workerId, function(ok) {
if (!ok) {
2015-07-23 17:19:53 +02:00
2015-09-09 15:18:18 +02:00
db.createUser(
workerId,
2015-09-09 15:18:18 +02:00
req.body.inputAge,
req.body.inputGender === 'male',
req.body.input3dskills,
req.body.inputLastTime,
function(id) {
req.session.userId = id;
req.session.save();
res.redirect('/prototype/tutorial');
}
);
2015-07-23 17:19:53 +02:00
} else {
req.session.identificationFailed = true;
res.redirect('/user-study');
}
2015-07-23 17:19:53 +02:00
});
};