Showing
1 changed file
with
35 additions
and
0 deletions
... | @@ -42,4 +42,39 @@ router.get('/', function(req, res, next) { | ... | @@ -42,4 +42,39 @@ router.get('/', function(req, res, next) { |
42 | }); | 42 | }); |
43 | 43 | ||
44 | 44 | ||
45 | +router.post('/update', function(req, res, next) { | ||
46 | + var user_id=req.body.user_id; | ||
47 | + var user_pw=req.body.user_pw; | ||
48 | + var user_pw2=req.body.user_pw2; | ||
49 | + var user_email=req.body.user_email; | ||
50 | + // var user_phone=req.body.user_phone; | ||
51 | + | ||
52 | + if(user_pw===user_pw2) { | ||
53 | + console.log(user_pw2); | ||
54 | + // user_pw=CryptoJS.AES.encrypt(user_pw, 'secret key 123'); | ||
55 | + user_pw=cryptoM.encrypt(user_pw); | ||
56 | + var sql='UPDATE users SET user_pw = ?, user_email= ? WHERE user_id = ?'; | ||
57 | + var values=[user_pw, user_email, user_id]; | ||
58 | + connection.query(sql, values , function (err) { | ||
59 | + if (err) { | ||
60 | + console.log("updating user failed"); | ||
61 | + //res.send({result:false}); | ||
62 | + //throw err; | ||
63 | + } else { | ||
64 | + console.log("user updated successfully"); | ||
65 | + res.redirect('back'); | ||
66 | + } | ||
67 | + }); | ||
68 | + } | ||
69 | + else | ||
70 | + { | ||
71 | + console.log("비밀번호가 일치하지 않습니다."); | ||
72 | + res.send({result:false}); | ||
73 | + res.redirect('back'); | ||
74 | + } | ||
75 | +}); | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | + | ||
45 | module.exports = router; | 80 | module.exports = router; | ... | ... |
-
Please register or login to post a comment