account.js
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* [个人中心]个人设置-账号安全部分
* @author: jiangmin
* @date: 2016/07/13
*/
'use strict';
const accountModel = require('../models/account');
/**
* 修改密码
* @param req
* @param res
*/
const changePwd = (req, res) => {
let uid = req.user.uid;
// let uid = req.user.uid||"20000190" ;
let pwd = req.body.password;
accountModel.changePwd(uid, pwd).then(result=> {
// console.log("修改result", result);
res.send(result);
});
};
/**
* 验证手机号码
* @param req
* @param res
*/
const checkVerifyMobile = (req, res)=> {
let uid = req.user.uid;
// let uid = req.user.uid||"20000190";
let mobile = req.body.mobile;
let area = req.body.area;
// console.log(uid, mobile, area);
accountModel.checkVerifyMobile(uid, mobile, area).then(result=> {
// console.log("验证手机号码", result);
res.send(result);
});
};
/**
* 发送短信
* @param req
* @param res
*/
const sendMobileMsg = (req, res)=> {
let uid = req.user.uid;
// let uid = req.user.uid||"20000190";
let mobile = req.body.mobile;
let area = req.body.area || '+86';
// console.log(uid, mobile, area);
accountModel.sendMobileMsg(uid, mobile, area).then(result=> {
// console.log("发送短信result", result);
res.send(result);
});
};
/**
* 验证短信
* @param req
* @param res
*/
const checkVerifyMsg = (req, res)=> {
let code = req.body.code;
let mobile = req.body.mobile;
let area = req.body.area || '+86';
accountModel.checkVerifyMsg(code, mobile, area).then(result=> {
// console.log("短信验证result", result);
res.send(result);
});
};
/**
* 发送验证邮件
* @param req
* @param res
*/
const sendVerifyEmail = (req, res)=> {
let uid = req.user.uid;
// let uid = req.user.uid||"20000190";
let email = req.body.email;
accountModel.sendVerifyEmail(uid, email).then(result=> {
// console.log("发送验证邮件result", result);
res.send(result);
});
};
module.exports = {
changePwd: changePwd,
sendMobileMsg: sendMobileMsg,
checkVerifyMsg: checkVerifyMsg,
sendVerifyEmail: sendVerifyEmail,
checkVerifyMobile: checkVerifyMobile
};