本人自写接口,为了过滤掉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'}
}
);