-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
50 lines (41 loc) · 1.25 KB
/
functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var dataFields = {};
exports.defineTable = function (tableName, obj) {
dataFields[tableName] = obj;
}
var sampleData = {};
exports.getFormSpecs = function () {
return dataFields;
}
exports.getSampleData = function () {
return sampleData;
}
exports.pushSampleData = function (tableName, valueList) {
sampleData[tableName] = {};
var dstLength = dataFields[tableName].length;
var srcLength = valueList.length;
var fields = dataFields[tableName];
var i;
for (i = 0; i < dstLength; i++) {
if (i > srcLength) {
break;
}
sampleData[tableName][fields[i].name] = valueList[i];
}
if (i < dstLength) {
console.error(i + " < " + tableName + ".length for: ");
console.error(" " + valueList.join(', '));
}
}
exports.restrict = function (req, res, next) {
//see <http://toon.io/on-passportjs-specific-use-cases/>
//express-specific improvements from <https://scotch.io/tutorials/route-middleware-to-check-if-a-user-is-authenticated-in-node-js>
//if (req.isUnAuthenticated())
return next;
// TODO: authenticate instead:
// if (!req.user || !req.user.username) {
// //only Angular (?) return req.json(403, {message: 'Access denied, please log in'});
// var results = {"error":"Access denied"};
// res.send(results);
// }
// else return next();
}