user.js
760 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
let users = new Array();
function addUser(userInfo){
let result = "";
let isExist = false;
for(var i = 0; i < users.length; i++){
if(users[i].email === userInfo.email){
isExist = true;
break;
}
}
if(!isExist){
users.push(userInfo);
result = "SUCCESS";
}
else{
result = "EXIST";
}
return result;
}
function getUser(simpleUserInfo){
let userEmail = simpleUserInfo.email;
let userPw = simpleUserInfo.pw;
let result = "";
for(var i = 0; i < users.length; i++){
if(userEmail === users[i].email && userPw === users[i].pw){
result = users[i].keyword;
}
}
return result;
}
module.exports = {addUser, getUser};