Commit ·
4a394a0
1
Parent(s): e5b32fa
修改用户密码加密
Browse files- hapi-think/lib/index.js +5 -1
hapi-think/lib/index.js
CHANGED
|
@@ -392,6 +392,10 @@ exports.plugin = {
|
|
| 392 |
const {email,headImgUrl,mobile,password,oldPassword,checkPassword} = data["$set"];
|
| 393 |
if(params.type === "password"){
|
| 394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
if(oldPassword !== user.password){
|
| 396 |
Error("原密码输入错误!");
|
| 397 |
}
|
|
@@ -412,7 +416,7 @@ exports.plugin = {
|
|
| 412 |
Error("当前密码与旧密码不能一致!");
|
| 413 |
}
|
| 414 |
|
| 415 |
-
await mongo.db.collection('user').updateOne({_id:user._id},{$set:{password}});
|
| 416 |
|
| 417 |
}else{
|
| 418 |
|
|
|
|
| 392 |
const {email,headImgUrl,mobile,password,oldPassword,checkPassword} = data["$set"];
|
| 393 |
if(params.type === "password"){
|
| 394 |
|
| 395 |
+
//获取用户原密码
|
| 396 |
+
const passwordKey = userType.token.split('ndcl')[1];
|
| 397 |
+
user.password = await Iron.unseal(user.password, passwordKey, Iron.defaults);
|
| 398 |
+
|
| 399 |
if(oldPassword !== user.password){
|
| 400 |
Error("原密码输入错误!");
|
| 401 |
}
|
|
|
|
| 416 |
Error("当前密码与旧密码不能一致!");
|
| 417 |
}
|
| 418 |
|
| 419 |
+
await mongo.db.collection('user').updateOne({_id:user._id},{$set:{password:await Iron.seal(password, passwordKey, Iron.defaults)}});
|
| 420 |
|
| 421 |
}else{
|
| 422 |
|