home.ctrl.js
1.32 KB
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
51
52
53
"use strict";
const User = require("../../models/User");
const output = {
hello: (req, res) => {
res.render("home/index");
},
login: (req, res) => {
res.render("home/login");
},
register: (req, res) => {
res.render("home/register");
}
};
const process = {
login: async (req, res) => {
const user = new User(req.body);
const response = await user.login();
return res.json(response);
},
register: async (req, res) => {
const user = new User(req.body);
const response = await user.register();
return res.json(response);
},
// 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,
};