-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
37 lines (31 loc) · 761 Bytes
/
Copy pathutil.js
File metadata and controls
37 lines (31 loc) · 761 Bytes
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
const data = require('./data.json')
function authenticate(user, password) {
if (data[user] && data[user].password == password) return data[user].friendlyName
else {
return "FAIL"
}
}
function generateId(user) {
return user + (Math.random() * 100);
}
function getLists(user) {
var returnList = {};
for (var key in data) {
if (key != user)
returnList[key] = { friendlyName: data[key].friendlyName, wishes: data[key].wishes }
}
return returnList;
}
function getOwnList(user) {
var items = [];
for (var wish in data[user].wishes) {
items.push(data[user].wishes[wish].value)
}
return items;
}
module.exports = {
authenticate,
generateId,
getLists,
getOwnList
}