Showing
1 changed file
with
23 additions
and
0 deletions
... | @@ -30,7 +30,30 @@ router.post('/update', function(req, res, next) { | ... | @@ -30,7 +30,30 @@ router.post('/update', function(req, res, next) { |
30 | } | 30 | } |
31 | }); | 31 | }); |
32 | 32 | ||
33 | +router.post('/delete', function(req, res, next) { | ||
34 | + var user_id=req.body.user_id; | ||
35 | + var user_pw=req.body.user_pw; | ||
36 | + var user_pw_temp =cryptoM.encrypt(user_pw); //받아온 비밀번호를 암호화화여 임시변수에 저장 | ||
37 | + | ||
38 | + var sqlquery = "SELECT user_pw FROM users WHERE user_id = ?"; // user_id의 비밀번호를 가져옴 | ||
39 | + connection.query(sqlquery, [user_id], function (err, rows) { | ||
40 | + if (rows[0].user_pw == user_pw_temp) { // 받아온 비밀번호와 user_id의 비밀번호가 같은지 대조 | ||
41 | + var sql = 'delete from users where user_id = ?'; // 만약 같다면 삭제 진행 | ||
42 | + var values = [user_id]; | ||
43 | + connection.query(sql, values, function (err) { | ||
44 | + if (err) { | ||
45 | + console.log("delete user failed"); | ||
46 | + throw err; | ||
47 | + } else { | ||
48 | + res.status(200).send('delete'); | ||
33 | 49 | ||
50 | + } | ||
51 | + }); | ||
52 | + } else { | ||
53 | + res.status(404).send(err); | ||
54 | + } | ||
55 | + }); | ||
34 | 56 | ||
57 | +}); | ||
35 | 58 | ||
36 | module.exports = router; | 59 | module.exports = router; | ... | ... |
-
Please register or login to post a comment