Commit a4642df5 by 蒋勇

d

parent ed80e855
...@@ -336,6 +336,51 @@ class AccessAuthAPI extends APIBase { ...@@ -336,6 +336,51 @@ class AccessAuthAPI extends APIBase {
return system.getResultSuccess({ auth_url: authUrl, opencode: opencode }); return system.getResultSuccess({ auth_url: authUrl, opencode: opencode });
} }
/** /**
* modifyLoginNameByOldMobile
* 按照手机号和密码改变登录账号
* oldmobile
* pwd
* newmobile
* vcode
* 返回
* {
* status:0-成功 -1:失败
* msg:''--消息提示
* data:-130--已经存在账户
* }
*/
async modifyLoginNameByOldMobile(pobj, qobj, req){
var appid=req.app.id;
var appkey=req.app.appkey;
if (!pobj.oldmobile) {
return system.getResult(null, "原电话号码不能为空.");
}
if (!pobj.pwd) {
return system.getResult(null, "密码不能为空.");
}
//检查原账户是否存在
var u=await this.userSve.findUserByMobilePwd(appid,pobj.oldmobile,pobj.pwd);
if(!u){
return system.getResult(null, "要修改的账户不存在.");
}
if (!pobj.newmobile) {
return system.getResult(null, "新电话号码不能未空.");
}
if (!pobj.vcode) {
return system.getResult(null, "验证码不能未空.");
}
var cacheCode = await this.cacheManager["VCodeCache"].cache(appkey + "_" + pobj.newmobile, null);
if (pobj.vcode != cacheCode.vcode) {
return system.getResultFail(-1, "验证码校验不成功,请重新获取验证码验证.",system.verifyVCodeFail);
}
//修改为新的账号
var ruser = await this.userSve.updateUserMobile(u,pobj.newmobile);
if(!ruser){
return system.getResultFail(-1,"账号已经存在",-130);
}
return system.getResult(ruser);
}
/**
* 按照手机号和验证码修改密码 * 按照手机号和验证码修改密码
*/ */
async modiPasswordByMobile(pobj, qobj, req){ async modiPasswordByMobile(pobj, qobj, req){
......
...@@ -11,6 +11,32 @@ class UserService extends ServiceBase { ...@@ -11,6 +11,32 @@ class UserService extends ServiceBase {
this.roleDao = system.getObject("db.auth.roleDao"); this.roleDao = system.getObject("db.auth.roleDao");
this.compDao=system.getObject("db.common.companyDao"); this.compDao=system.getObject("db.common.companyDao");
} }
//按照电话和密码查询出用户
async findUserByMobilePwd(appid,mobile,pwd){
var pwd=await super.getEncryptStr(pwd);
var mu=await this.db.models.user.findOne({
where:{app_id:appid,mobile:mobile,password:pwd}
});
return mu;
}
//修改为新账号
async updateUserMobile(u,newmobile){
var existNew=await this.db.models.user.findOne({
where:{app_id:u.app_id,mobile:newmobile}
});
if(existNew){
return null;
}
u.userName=newmobile;
u.mobile=newmobile;
u.save();
var ac=await this.db.models.account.findById(u.account_id);
ac.userName=newmobile;
ac.mobile=newmobile;
ac.save();
return u;
}
async modiPasswordByMobile(appid,mobile,newpwd){ async modiPasswordByMobile(appid,mobile,newpwd){
var self=this; var self=this;
var newp=await super.getEncryptStr(newpwd); var newp=await super.getEncryptStr(newpwd);
...@@ -388,3 +414,14 @@ module.exports = UserService; ...@@ -388,3 +414,14 @@ module.exports = UserService;
// }).catch(function(e){ // }).catch(function(e){
// console.log(e); // console.log(e);
// }); // });
// (async ()=>{
// var us=new UserService();
// var u= await us.findUserByMobilePwd(2,'123456789','123');
// console.log(u.userName);
// var x=await us.updateUserMobile(u,'987456');
// if(!x){
// console.log("exit...");
// }
// console.log("ok...");
// })();
...@@ -7,10 +7,10 @@ var settings = { ...@@ -7,10 +7,10 @@ var settings = {
}, },
database: { database: {
dbname: "paas", dbname: "paas",
user: "write", user: "root",
password: "write", password: "123456",
config: { config: {
host: '192.168.18.237', host: '192.168.4.119',
port: 3306, port: 3306,
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment