Commit e087d5ce by 宋毅

tn

parent 17334402
......@@ -8,6 +8,7 @@ class AccessAuthAPI extends APIBase {
this.apitradeSvr = system.getObject("service.common.apitradeSve");
this.authUtils = system.getObject("util.businessManager.authUtils");
this.userSve = system.getObject("service.auth.userSve");
this.vCodeExTime = 120;//验证码缓存秒数
}
/*查询注册用户的信息sys*/
async queryRegUser(pobj, query, req) {
......@@ -47,7 +48,7 @@ class AccessAuthAPI extends APIBase {
return system.getResultFail(system.redoFail, "操作过于频繁,请勿重复获取", system.redoFail);
}
pobj.reqType = "otherVcode";
var vcodeResult = await this.cacheManager["VCodeCache"].cache(cacheKeyStr, pobj, 120, null);
var vcodeResult = await this.cacheManager["VCodeCache"].cache(cacheKeyStr, pobj, this.vCodeExTime, null);
return system.getResult(vcodeResult);
}
/**
......@@ -78,11 +79,13 @@ class AccessAuthAPI extends APIBase {
if (tmplCode && tmplCode.indexOf("SMS_") < 0) {
return system.getResult(null, "模版编码有误");
}
var tmpReslut = await this.cacheManager["VCodeCache"].getCache(appkey + "_" + mobile);
var cacheKeyStr = appkey + "_" + pobj.mobile;
var tmpReslut = await this.cacheManager["VCodeCache"].getCache(cacheKeyStr);
if (tmpReslut) {
return system.getResultFail(system.redoFail, "操作过于频繁,请勿重复获取", system.redoFail);
}
var vcodeResult = await this.cacheManager["VCodeCache"].cache(appkey + "_" + mobile, tmplCode, 120, signName);
pobj.reqType = "defaultOtherVcode";
var vcodeResult = await this.cacheManager["VCodeCache"].cache(cacheKeyStr, pobj, this.vCodeExTime, null);
return system.getResult(vcodeResult);
}
/**
......@@ -97,11 +100,13 @@ class AccessAuthAPI extends APIBase {
if (!mobile) {
return system.getResult(null, "电话号码不能为空.");
}
var tmpReslut = await this.cacheManager["VCodeCache"].getCache(appkey + "_" + mobile);
var cacheKeyStr = appkey + "_" + pobj.mobile;
var tmpReslut = await this.cacheManager["VCodeCache"].getCache(cacheKeyStr);
if (tmpReslut) {
return system.getResultFail(system.redoFail, "操作过于频繁,请勿重复获取", system.redoFail);
}
var vcodeResult = this.cacheManager["VCodeCache"].cache(appkey + "_" + mobile, null, 120);
pobj.reqType = "defaultVcode";
var vcodeResult = this.cacheManager["VCodeCache"].cache(cacheKeyStr, pobj, this.vCodeExTime, null);
return system.getResult(vcodeResult);
}
async authAccessKey(pobj, query, req) {
......@@ -276,7 +281,8 @@ class AccessAuthAPI extends APIBase {
if (!pobj.openid) {
return system.getResult(null, "openid不能未空.");
}
var cacheCode = await this.cacheManager["VCodeCache"].cache(appkey + "_" + pobj.mobile, null);
var cacheKeyStr = appkey + "_" + pobj.mobile;
var cacheCode = await this.cacheManager["VCodeCache"].getCache(cacheKeyStr);
if (!cacheCode || pobj.vcode != cacheCode.vcode) {
return system.getResultFail(system.verifyVCodeFail, "验证码校验不成功,请重新获取验证码验证.", system.verifyVCodeFail);
}
......@@ -394,7 +400,7 @@ class AccessAuthAPI extends APIBase {
return system.getResult(null, "新密码不能未空.");
}
var cacheKeyStr = appkey + "_" + pobj.mobile;
var cacheCode = await this.cacheManager["VCodeCache"].cache(cacheKeyStr, null);
var cacheCode = await this.cacheManager["VCodeCache"].getCache(cacheKeyStr);
if (!cacheCode || pobj.vcode != cacheCode.vcode) {
return system.getResultFail(-1, "验证码校验不成功,请重新获取验证码验证." + pobj.vcode + "--" + cacheCode.vcode, system.verifyVCodeFail);
}
......
......@@ -17,29 +17,24 @@ class VCodeCache extends CacheBase {
return "g_vcode:appkey_"
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
//【XXX】您的验证码是:602639(5分钟内有效),工作人员不会索取,请勿泄露。-------描述在模板中配置
var pobj = val;
var vcode = await this.smsUtil.getUidStr(6, 10);
if (!pobj) {
//inputkey采用appkey_mobile的形式
var mobile = inputkey.split("_")[1];
var tmplCode = val;
var signName = items ? items[0] : "";
// var content=tmpl.replace(/\|vcode\|/g,vcode);
//this.smsUtil.sendMsg(mobile,content);
if (!tmplCode && !signName) {
this.smsUtil.sendMsg(mobile, vcode);
} //tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else {
this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode }));
}
return JSON.stringify({ vcode: vcode });
}
if (pobj.reqType == "otherVcode") {
//【XXX】您的验证码是:602639(5分钟内有效),工作人员不会索取,请勿泄露。-------描述在模板中配置
pobj.msgContent = vcode;
if (pobj && pobj.reqType) {
switch (pobj.reqType) {
case "defaultVcode":
this.smsUtil.sendMsg(pobj.mobile, vcode);
break;
case "defaultOtherVcode":
this.smsUtil.aliSendMsg(pobj.mobile, pobj.tmplCode, pobj.signName, JSON.stringify({ code: vcode }));
break;
case "otherVcode":
this.smsUtil.aliOtherSendMsg(pobj.mobile, pobj.accessKeyId, pobj.accessKeySecret, pobj.tmplCode,
pobj.signName, JSON.stringify({ code: vcode }));
break;
default:
break;
}
}
return JSON.stringify({ vcode: vcode });
}
......
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