home.ctrl.js
953 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
38
39
40
"use strict";
const UserStorage = require("../../models/UserStorage");
const output = {
hello: (req, res) => {
res.render("home/index");
},
login: (req, res) => {
res.render("home/login");
},
};
const process = {
login: (req, res) => {
const id = req.body.id,
password = req.body.password;
const users = UserStorage.getUsers("id", "password");
// console.log(UserStorage.getUsers("id", "password","name"));
const response = {};
if (users.id.includes(id)) {
const idx = users.id.indexOf(id);
if (users.password[idx] === password) {
response.success = true;
return res.json(response);
}
}
response.success = false;
response.msg = "로그인에 실패하였습니다."
return res.json(response);
},
};
module.exports = {
output,
process,
};