Showing
1 changed file
with
10 additions
and
16 deletions
... | @@ -32,14 +32,7 @@ app.use(bodyParser.urlencoded({ limit: '1gb', extended: false })); | ... | @@ -32,14 +32,7 @@ app.use(bodyParser.urlencoded({ limit: '1gb', extended: false })); |
32 | 32 | ||
33 | app.post('/api/register', (req, res) => { | 33 | app.post('/api/register', (req, res) => { |
34 | 34 | ||
35 | - const new_user = new Users(req.body); | 35 | + Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { |
36 | - | ||
37 | - new_user.save((err) => { | ||
38 | - if (err) return res.status(500).json({ registerSuccess: false}); | ||
39 | - else return res.status(200).json({ registerSuccess: true}); | ||
40 | - }) | ||
41 | - | ||
42 | - /*Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { | ||
43 | if (err) return res.status(500).json({ registerSuccess: '-1'}); | 36 | if (err) return res.status(500).json({ registerSuccess: '-1'}); |
44 | else if (user){ | 37 | else if (user){ |
45 | res.json({ registerSuccess: '0'}); | 38 | res.json({ registerSuccess: '0'}); |
... | @@ -52,19 +45,20 @@ app.post('/api/register', (req, res) => { | ... | @@ -52,19 +45,20 @@ app.post('/api/register', (req, res) => { |
52 | else return res.status(200).json({ registerSuccess: '1'}); | 45 | else return res.status(200).json({ registerSuccess: '1'}); |
53 | }); | 46 | }); |
54 | } | 47 | } |
55 | - });*/ | 48 | + }); |
56 | 49 | ||
57 | }); | 50 | }); |
58 | 51 | ||
59 | app.post('/api/login', (req, res) => { | 52 | app.post('/api/login', (req, res) => { |
60 | - Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { | 53 | + |
61 | - if (err) return res.status(500).json({ message: '에러가 발생하였습니다.' }); | 54 | + Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { |
62 | - else if (user){ | 55 | + if (err) return res.status(500).json({ loginSuccess: false }); |
63 | - logid={id:user.id,password:user.password,name:user.name,gender:user.gender}; | 56 | + else if (user) { |
64 | - return res.status(200).json({ message: '로그인 되었습니다.', data: user }); | 57 | + // logid={id:user.id,password:user.password,name:user.name,gender:user.gender}; |
58 | + return res.status(200).json({ loginSuccess: true }); | ||
65 | } | 59 | } |
66 | - else return res.status(404).json({ message: '아이디와 비밀번호를 다시 확인해주세요.' }); | 60 | + else return res.status(404).json({ loginSuccess: false }); |
67 | - }); | 61 | + }); |
68 | }); | 62 | }); |
69 | 63 | ||
70 | app.post('/api/logout',(req,res)=>{ | 64 | app.post('/api/logout',(req,res)=>{ | ... | ... |
-
Please register or login to post a comment