Authored by 郭成尧

ResetModel

@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-04-13 10:21:07 3 * @Date: 2017-04-13 10:21:07
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-24 10:52:08  
6 */ 5 */
7 6
8 /* ******************** 7 /* ********************
@@ -13,7 +12,7 @@ @@ -13,7 +12,7 @@
13 12
14 const config = global.yoho.config; 13 const config = global.yoho.config;
15 const utils = require(global.utils); 14 const utils = require(global.utils);
16 -const reset = require('../models/reset'); 15 +const ResetModel = require('../models/reset');
17 16
18 const passwordResetPage = (req, res) => { 17 const passwordResetPage = (req, res) => {
19 let passwordWeakObj = req.session.passwordWeak; 18 let passwordWeakObj = req.session.passwordWeak;
@@ -60,7 +59,7 @@ const passwordReset = (req, res, next) => { @@ -60,7 +59,7 @@ const passwordReset = (req, res, next) => {
60 59
61 req.session.passwordWeak = null; 60 req.session.passwordWeak = null;
62 61
63 - reset.resetPassword({ 62 + req.ctx(ResetModel).resetPassword({
64 uid: uid, 63 uid: uid,
65 oldPwd: req.body.oldPwd, 64 oldPwd: req.body.oldPwd,
66 newPwd: req.body.newPwd, 65 newPwd: req.body.newPwd,
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-04-13 10:25:56 3 * @Date: 2017-04-13 10:25:56
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-14 17:07:09  
6 */ 5 */
7 6
8 /* ****************** 7 /* ******************
@@ -10,24 +9,27 @@ @@ -10,24 +9,27 @@
10 ********************/ 9 ********************/
11 10
12 'use strict'; 11 'use strict';
13 -  
14 -const api = global.yoho.API;  
15 const aes = require('./aes-pwd'); 12 const aes = require('./aes-pwd');
16 13
17 -/**  
18 - * 重置密码  
19 - * @param {*} params  
20 - */  
21 -const resetPassword = (params) => {  
22 - return api.post('', {  
23 - method: 'app.password.modPwdByCode',  
24 - uid: params.uid,  
25 - oldPwd: aes.aesPwd(params.oldPwd),  
26 - newPwd: aes.aesPwd(params.newPwd),  
27 - token: params.token  
28 - });  
29 -}; 14 +class ResetModel extends global.yoho.BaseModel {
  15 + constructor(ctx) {
  16 + super(ctx);
  17 + }
  18 +
  19 + /**
  20 + * 重置密码
  21 + * @param {*} params
  22 + */
  23 + resetPassword(params) {
  24 + return this.post({data: {
  25 + method: 'app.password.modPwdByCode',
  26 + uid: params.uid,
  27 + oldPwd: aes.aesPwd(params.oldPwd),
  28 + newPwd: aes.aesPwd(params.newPwd),
  29 + token: params.token
  30 + }});
  31 + }
  32 +}
  33 +
30 34
31 -module.exports = {  
32 - resetPassword  
33 -}; 35 +module.exports = ResetModel;