Commit 9f769970 by 宋毅

tj

parent 257ab0f4
......@@ -37,19 +37,46 @@ class AccessAuthAPI extends APIBase {
return result;
}
async opActionProcess(action_process, action_type, action_body, pobj, req) {
var opResult = null;
var opResult = system.getResult(null, "req Failure");
var userpin = this.getUUID();
action_body.appInfo = req.appInfo;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getVerifyCode":
opResult = await this.opPlatformUtils.getVerifyCodeByMoblie(action_body, action_process, req);
if (opResult.status == 0) {
return system.getResultSuccess()
}
break;
case "loginUserByChannelUserId":
var userpin = this.getUUID();
opResult = await this.utilsAuthSve.loginUserByChannelUserId(action_body, action_process, userpin, req);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
}
break;
case "userPinByLgoin":
opResult = await this.utilsAuthSve.getReqUserPinByLgoin(action_body, action_process, userpin, req);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
}
break;
case "userPinByLgoinVcode":
action_body.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(action_body, action_process, userpin, req);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
}
break;
case "userPinByRegister":
action_body.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(action_body, action_process, userpin, req);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
}
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -44,7 +44,9 @@ class CacheBase {
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null") {
return system.getResultFail(system.cacheInvalidation, "cache is invalidation")
} else {
this.redisClient.set(cachekey, cacheValue, ex);
if (ex) {
this.redisClient.set(cachekey, cacheValue, ex);
}
return JSON.parse(cacheValue);
}
}
......
......@@ -13,13 +13,8 @@ class AppUserPinByChannelUserId extends CacheBase {
return settings.cacheprefix + "_userPin:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var app_hosts = val;
if (!app_hosts) {
return system.getResult(null, "app_hosts can not be empty");
}
var acckapp = await this.restClient.execPost(val, settings.centerAppUrl() + "auth/accessAuth/loginUserByChannelUserId");
var result = acckapp.stdout;
console.log(acckapp.stdout, "AppTokenByHostsCache............. acckapp.stdout..........")
if (result) {
var tmp = JSON.parse(result);
return tmp;
......
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class AppUserPinByLoginPwdCache extends CacheBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appuserDao = system.getObject("db.dbapp.appuserDao");
this.restClient = system.getObject("util.restClient");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_userPin:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var acckapp = await this.restClient.execPost(val, settings.centerAppUrl() + "auth/accessAuth/login");
var result = acckapp.stdout;
if (result) {
var tmp = JSON.parse(result);
return tmp;
}
return system.getResult(null, "data is empty");
}
}
module.exports = AppUserPinByLoginPwdCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class AppUserPinByLoginVcodeCache extends CacheBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appuserDao = system.getObject("db.dbapp.appuserDao");
this.restClient = system.getObject("util.restClient");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_userPin:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var acckapp = await this.restClient.execPost(val, settings.centerAppUrl() + "auth/accessAuth/loginByVerifyCode");
var result = acckapp.stdout;
if (result) {
var tmp = JSON.parse(result);
return tmp;
}
return system.getResult(null, "data is empty");
}
}
module.exports = AppUserPinByLoginVcodeCache;
......@@ -7,7 +7,6 @@ class UtilsAuthSve {
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async loginUserByChannelUserId(action_body, action_process, userpin, req) {
action_body.appInfo = req.appInfo;
var opResult = null;
switch (action_process) {
case "gsbhome":
......@@ -24,6 +23,15 @@ class UtilsAuthSve {
return userinfo;
}
//---------------登录-----------------------------------------------------
async getReqUserPinByLgoin(action_body, action_process, userpin, req) {
var userinfo = await this.opPlatformUtils.getReqUserPinByLgoin(action_body, userpin);
return userinfo;
}
async getReqUserPinByLgoinVcode(action_body, action_process, userpin, req) {
var userinfo = await this.opPlatformUtils.getReqUserPinByLgoinVcode(action_body, userpin, action_body.reqType);
return userinfo;
}
}
module.exports = UtilsAuthSve;
......@@ -152,7 +152,7 @@ class OpPlatformUtils {
return system.getResultSuccess(restResult.data);
}
//-----新的方式
//------------------------新的方式------------------------------------------------------------------------------------
async getReqTokenByHosts(appHosts, tokenValue) {
if (!appHosts) {
return system.getResult(null, "appHosts can not be empty");
......@@ -161,6 +161,7 @@ class OpPlatformUtils {
var result = await cacheManager["AppTokenByHostsCache"].cache(tokenValue, appHosts, system.exTime);
return result;
}
async getReqUserPinByChannelUserId(actionBody, userPinValue) {
if (!actionBody.channelUserId) {
return system.getResult(null, "actionBody.channelUserId can not be empty");
......@@ -169,6 +170,47 @@ class OpPlatformUtils {
var result = await cacheManager["AppUserPinByChannelUserId"].cache(userPinValue, actionBody, system.exTime);
return result;
}
async getReqUserPinByLgoin(actionBody, userPinValue) {
if (!actionBody.userName) {
return system.getResult(null, "actionBody.userName can not be empty");
}
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppUserPinByLoginPwdCache"].cache(userPinValue, actionBody, system.exTime);
return result;
}
async getReqUserPinByLgoinVcode(actionBody, userPinValue, reqType) {
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty");
}
if (!actionBody.vcode) {
return system.getResult(null, "actionBody.vcode can not be empty");
}
if (reqType == "reg") {
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppUserPinByLoginVcodeCache"].cache(userPinValue, actionBody, system.exTime);
return result;
}
async getVerifyCodeByMoblie(actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "pobj.mobile can not be empty !");
}
var acckapp = await this.restClient.execPost(actionBody, settings.centerAppUrl() + "auth/accessAuth/getVerifyCodeByMoblie");
var result = acckapp.stdout;
if (result) {
var tmp = JSON.parse(result);
return tmp;
}
return system.getResult(null, "data is empty");
}
}
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