loopback修改密码功能(去掉邮箱验证了)

本人自写接口,为了过滤掉loopback中登录是需要的eamil验证
正常的验证都是用邮箱来验证的,而且loopback自带的加密
Account.hashPassword(options.password);以后会逐步完善,一点一滴汇聚江河湖海,加油!
/**
 *  重置密码,修改密码  接口
 * @param options
 * @param cb
 */
Account.resetPassword = function(options, cb) {
  console.log(options);
  this.findOne({ "where" : { "id":options.id }},function(err,account) {
    var pwd=Account.hashPassword(options.password);
    var forwardFilter={ "id" : options.id };
    //更新的值
    var forwardData={ "password" : pwd };
    //更新加密过的password
    Account.update(forwardFilter,forwardData,function(err,cobj){
      if(err){
        cb(null,{"ret":-1,"msg":"重置密码失败"});
      }else{
        cb(null,{"ret":1,"msg":"重置密码成功"});
      }
    });
  });
};
Account.remoteMethod(
  'resetPassword',
  {
    description: 'Reset password for a user with userId.',
    accepts: [
      {arg: 'options', type: 'object', required: true, http: {source: 'body'}}
    ],
    http: {verb: 'post', path: '/reset'},
    returns: {arg: 'result',type:'string'}
  }
);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值