Commit b16f2e25 by 宋毅

tj

parent 439d1842
......@@ -29,11 +29,11 @@ class AccessAuthAPI extends APIBase {
var result = await this.opPlatformUtils.getReqUserPinByLgoin(pobj);
return result;
}
async getLoginByUserName(pobj, qobj, req) {//通过账户获取用户信息----------------------------actionBody.userName
if (!pobj.actionBody.userName) {
return system.getResult(null, "actionBody.userName can not be empty !");
async getUserPinByChannelUserId(pobj, qobj, req) {//通过账户获取用户信息----------------------------actionBody.channelUserId
if (!pobj.actionBody.channelUserId) {
return system.getResult(null, "actionBody.channelUserId can not be empty !");
}
var result = await this.opPlatformUtils.getLoginByUserName(pobj);
var result = await this.opPlatformUtils.getUserPinByChannelUserId(pobj);
return result;
}
......@@ -58,13 +58,10 @@ class AccessAuthAPI extends APIBase {
if (!actionBody.newPwd) {
return system.getResult(null, "actionBody.newPwd can not be empty !");
}
if (!actionBody.userpin) {
return system.getResult(null, "actionBody.userpin can not be empty !");
}
var result = await this.opPlatformUtils.putUserPwdByMobile(pobj, actionBody);
return result;
}
async getLoginInfo(pobj, qobj, req) {//通过手机验证码修改用户密码
async getLoginInfo(pobj, qobj, req) {//通过userpin获取用户信息
var actionBody = pobj.actionBody;
if (!actionBody.userpin) {
return system.getResult(null, "actionBody.userpin can not be empty !");
......
......@@ -18,12 +18,13 @@ class AppUserPinByChannelUserIdCache extends CacheBase {
var actionBody = val.actionBody;
var appInfo = val.appInfo;
var createUserPwd = inputkey;//(格式:appInfo.uapp_key+”_“+actionBody.channelUserId)
var channelUserMoblie = actionBody.channelUserMoblie || "15010888888";
var channelUserMoblie = actionBody.mobile ? actionBody.mobile : actionBody.channelUserId;
var userInfo = await this.appuserDao.getItemByChannelUserId(actionBody.channelUserId, appInfo.uapp_id);
if (userInfo) {
if (userInfo.is_enabled != 1) {
return system.getResult(null, "user to item is Disable !");
}
userInfo.userpin = actionBody.userpin;
return system.getResultSuccess(userInfo);
}
var uUserInfo = await this.opPlatformUtils.createUserInfo(actionBody.channelUserId, channelUserMoblie,
......@@ -46,6 +47,7 @@ class AppUserPinByChannelUserIdCache extends CacheBase {
};
userInfo = await this.appuserDao.create(params);
}
userInfo.userpin = actionBody.userpin;
return system.getResultSuccess(userInfo);
}
}
......
......@@ -294,51 +294,23 @@ class OpPlatformUtils {
var result = await cacheManager["AppTokenByHostsCache"].cache(inputkey, actionBody, system.shortExTime);
return result;
}
// async getReqUserPinByChannelUserId(pobj) {
// var inputkey = pobj.appInfo.uapp_key + "_" + pobj.actionBody.channelUserId;
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppUserPinByChannelUserIdCache"].getCache(inputkey, pobj, system.shortExTime);
// if (result && result.status == 0) {
// return system.getResultFail(system.reDoLoginFail, "请勿重复登录");
// }
// result = await cacheManager["AppUserPinByChannelUserIdCache"].cache(inputkey, pobj, system.shortExTime);
// return result;
// if (!actionBody.channelUserId) {
// return system.getResult(null, "actionBody.channelUserId can not be empty");
// }
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppUserPinByChannelUserId"].cache(userPinValue, actionBody, system.exTime);
// return result;
// }
// async getReqUserPinByChannelUserId(actionBody, userPinValue) {
// if (!actionBody.channelUserId) {
// return system.getResult(null, "actionBody.channelUserId can not be empty");
// }
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppUserPinByChannelUserId"].cache(userPinValue, actionBody, system.exTime);
// return result;
// }
/**
* 通过账户和密码登录
* @param {*} pobj pobj.actionBody:{userName:XX}
* 渠道通过账户进行登录,有则返回用户信息,没有则创建用户---actionBody.channelUserId
* @param {*} pobj pobj.actionBody:{channelUserId:XX}
*/
async getLoginByUserName(pobj) {
var inputkey = pobj.appInfo.uapp_key + "_" + pobj.actionBody.userName;
async getUserPinByChannelUserId(pobj) {
var inputkey = pobj.appInfo.uapp_key + "_" + pobj.actionBody.channelUserId;
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppUserPinByUserNameCache"].getCache(inputkey);
var result = await cacheManager["AppUserPinByChannelUserIdCache"].getCache(inputkey);
if (result && result.status == 0) {
if (result.data.userpin) {
return system.getResultFail(system.reDoLoginFail, "请勿重复登录", { userpin: result.data.userpin || "" });
}else{
await cacheManager["AppUserPinByLoginPwdCache"].invalidate(inputkey);
await cacheManager["AppUserPinByLoginVcodeCache"].invalidate(inputkey);
await cacheManager["AppUserPinByUserNameCache"].invalidate(inputkey);
return system.getResultFail(system.reDoLoginFail, "请勿重复处理", { userpin: result.data.userpin || "" });
} else {
await this.clearLoginCache(inputkey);
}
}
var result = await cacheManager["AppUserPinByUserNameCache"].cache(inputkey, pobj, system.shortExTime);
var result = await cacheManager["AppUserPinByChannelUserIdCache"].cache(inputkey, pobj, system.shortExTime);
if (result && result.status == 0) {
var userpinKey = this.getUserPinKey(pobj.actionBody.userpin);
this.redisClient.setWithEx(userpinKey, JSON.stringify(result), system.exTime);
......@@ -430,14 +402,18 @@ class OpPlatformUtils {
var userResult = JSON.parse(userInfoResult);
if (userResult.status == 0) {
var inputkey = pobj.appInfo.uapp_key + "_" + userResult.data.channel_username;
var cacheManager = system.getObject("db.common.cacheManager");
await cacheManager["AppUserPinByLoginPwdCache"].invalidate(inputkey);
await cacheManager["AppUserPinByLoginVcodeCache"].invalidate(inputkey);
await cacheManager["AppUserPinByUserNameCache"].invalidate(inputkey);
await this.clearLoginCache(inputkey);
}
this.redisClient.delete(userpinKey);
return system.getResultSuccess();;
}
async clearLoginCache(inputkey) {
var cacheManager = system.getObject("db.common.cacheManager");
await cacheManager["AppUserPinByLoginPwdCache"].invalidate(inputkey);
await cacheManager["AppUserPinByLoginVcodeCache"].invalidate(inputkey);
await cacheManager["AppUserPinByUserNameCache"].invalidate(inputkey);
await cacheManager["AppUserPinByChannelUserIdCache"].invalidate(inputkey);
}
}
module.exports = OpPlatformUtils;
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