비밀번호변경

김형우·2022년 1월 7일
0

node.js

목록 보기
24/26

member.js

  • localhost:3000/member/mypage?menu=2
else if(menu === 2){
  console.log('menu=2 => req.body =>',req.body);
  // req.body.uid  아이디
  // req.body.upw  현재암호
  // req.body.upw1 바꿀암호
  const hash = crypto.createHmac('sha256', req.body.uid )
  					 .update(req.body.upw)
                     .digest('hex');
  const hash1 = crypto.createHmac('sha256', req.body.uid )
                      .update(req.body.upw1)
                      .digest('hex');                            
  const result = await coll.updateOne(
    {_id : req.body.uid, upw : hash}, // 조건 아이디와 암호가 일치하는지 조건
    { $set : {upw : hash1}},  // 변경할 내용
  )
  console.log('바뀔 pw => hash =>',hash);
  console.log('바뀐 pw => hash1 =>',hash1);
            
  console.log(result);
  if((await result).modifiedCount === 1){
    return res.send({status:200});
  }
  return res.send({status:0});
}
  • console.log('menu=2 => req.body =>',req.body);
  • console.log('바뀔 pw => hash =>', hash);
  • console.log('바뀐 pw => hash1 =>',hash1);
  • console.log(result);
profile
The best

0개의 댓글