Commit ecd342ca by 宋毅

tj

parent 0abc4777
...@@ -49,14 +49,9 @@ class AccessAuthAPI extends WEBBase { ...@@ -49,14 +49,9 @@ class AccessAuthAPI extends WEBBase {
}) })
break; break;
case "getNeedUserPinByChannelUserId"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户 case "getNeedUserPinByChannelUserId"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) { if (opResult.status != 0) {
return tmpOpResult; return opResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
} }
//获取需求信息 //获取需求信息
pobj.actionType = "getItemByChannelNeedNo"; pobj.actionType = "getItemByChannelNeedNo";
...@@ -68,15 +63,7 @@ class AccessAuthAPI extends WEBBase { ...@@ -68,15 +63,7 @@ class AccessAuthAPI extends WEBBase {
opResult.data.typeCode = needResult.data.typeCode opResult.data.typeCode = needResult.data.typeCode
break; break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户 case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break; break;
case "getVerifyCode"://获取默认模板的手机验证码---已优化 case "getVerifyCode"://获取默认模板的手机验证码---已优化
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(req, pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(req, pobj, pobj.actionBody);
...@@ -98,17 +85,17 @@ class AccessAuthAPI extends WEBBase { ...@@ -98,17 +85,17 @@ class AccessAuthAPI extends WEBBase {
} }
case "userPinByLgoinVcode"://通过短信登录信息---已优化 case "userPinByLgoinVcode"://通过短信登录信息---已优化
pobj.actionBody.reqType = "login"; pobj.actionBody.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(req, pobj, pobj.actionBody);
if (opResult.status == 0) { // if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin }) // return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
} // }
break; break;
case "userPinByRegister"://通过短信注册信息---已优化 case "userPinByRegister"://通过短信注册信息---已优化
pobj.actionBody.reqType = "reg"; pobj.actionBody.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(req, pobj, pobj.actionBody);
if (opResult.status == 0) { // if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin }) // return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
} // }
break; break;
case "putUserPwdByMobile"://通过手机验证码修改用户密码---已优化 case "putUserPwdByMobile"://通过手机验证码修改用户密码---已优化
opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody); opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody);
......
...@@ -42,15 +42,7 @@ class ChannelAccessAuthAPI extends WEBBase { ...@@ -42,15 +42,7 @@ class ChannelAccessAuthAPI extends WEBBase {
pobj.actionBody.channelUserId = aliUserResult.data.channelUserId; pobj.actionBody.channelUserId = aliUserResult.data.channelUserId;
pobj.actionBody.isAdmin = aliUserResult.data.isAdmin; pobj.actionBody.isAdmin = aliUserResult.data.isAdmin;
pobj.actionBody.isSuper = aliUserResult.data.isSuper; pobj.actionBody.isSuper = aliUserResult.data.isSuper;
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break; break;
case "getDingJsApiAuthInfo"://获取钉钉鉴权信息 case "getDingJsApiAuthInfo"://获取钉钉鉴权信息
opResult = await this.utilsChannelAuthSve.getDingJsApiAuthInfo(pobj, pobj.actionBody); opResult = await this.utilsChannelAuthSve.getDingJsApiAuthInfo(pobj, pobj.actionBody);
......
...@@ -32,15 +32,7 @@ class AccessAuthAPI extends APIBase { ...@@ -32,15 +32,7 @@ class AccessAuthAPI extends APIBase {
opResult = system.getResultSuccess(null, "测试成功"); opResult = system.getResultSuccess(null, "测试成功");
break; break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户 case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break; break;
case "getVerifyCode"://获取默认模板的手机验证码 case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(req, pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(req, pobj, pobj.actionBody);
...@@ -56,17 +48,17 @@ class AccessAuthAPI extends APIBase { ...@@ -56,17 +48,17 @@ class AccessAuthAPI extends APIBase {
break; break;
case "userPinByLgoinVcode"://通过短信登录信息 case "userPinByLgoinVcode"://通过短信登录信息
pobj.actionBody.reqType = "login"; pobj.actionBody.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(req, pobj, pobj.actionBody);
if (opResult.status == 0) { // if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin }) // return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
} // }
break; break;
case "userPinByRegister"://通过短信注册信息 case "userPinByRegister"://通过短信注册信息
pobj.actionBody.reqType = "reg"; pobj.actionBody.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody); opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(req, pobj, pobj.actionBody);
if (opResult.status == 0) { // if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin }) // return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
} // }
break; break;
case "putUserPwdByMobile"://通过手机验证码修改用户密码 case "putUserPwdByMobile"://通过手机验证码修改用户密码
opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody); opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody);
......
...@@ -127,10 +127,11 @@ class UtilsAuthService extends AppServiceBase { ...@@ -127,10 +127,11 @@ class UtilsAuthService extends AppServiceBase {
} }
/** /**
* 通过短信登录或注册信息 * 通过短信登录或注册信息
* @param {*} req
* @param {*} pobj * @param {*} pobj
* @param {*} actionBody {mobile:XXX,vcode:XXX,reqType:"reg",password:XXX-reqType为reg时有此值} * @param {*} actionBody {mobile:XXX,vcode:XXX,reqType:"reg",password:XXX-reqType为reg时有此值}
*/ */
async getReqUserPinByLgoinVcode(pobj, actionBody) { async getReqUserPinByLgoinVcode(req, pobj, actionBody) {
if (!actionBody.mobile) { if (!actionBody.mobile) {
return system.getResult(null, "电话号码不能为空"); return system.getResult(null, "电话号码不能为空");
} }
...@@ -142,18 +143,27 @@ class UtilsAuthService extends AppServiceBase { ...@@ -142,18 +143,27 @@ class UtilsAuthService extends AppServiceBase {
return system.getResult(null, "actionBody.password can not be empty"); return system.getResult(null, "actionBody.password can not be empty");
} }
} }
const result = await this.execPostByTimeOut(req, pobj, this.centerAppUrl + "auth/accessAuth/loginByVerifyCode", null, null); const tmpResult = await this.execPostByTimeOut(req, pobj, this.centerAppUrl + "auth/accessAuth/loginByVerifyCode", null, null);
if (result.status === 0 && result.data.status != 0) { if (!tmpResult || tmpResult.status != 0) {
return result.data; return system.getResult(null, tmpResult.msg);
}
if (!tmpResult.data || tmpResult.data.status != 0) {
return system.getResult(null, tmpResult.data.msg);
} }
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data));
let bodyInfo = {
env: settings.env,
user_id: tmpResult.data.data.id || 0,//新建立的用户时user_id为0
uapp_id: tmpResult.data.data.uapp_id,
userpin_secret: encrypt_info
};
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
//生成tokenid
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
expiresIn: 60 * 60 * 4 //单位秒,4小时
// var acckapp = await this.restClient.execPost(pobj, settings.centerAppUrl() + "auth/accessAuth/loginByVerifyCode"); });
// var result = acckapp.stdout; return system.getResultSuccess({ userpin: tokenid });
// if (result) {
// var tmp = JSON.parse(result);
// return tmp;
// }
return system.getResult(null, "data is empty");
} }
/** /**
...@@ -233,7 +243,7 @@ class UtilsAuthService extends AppServiceBase { ...@@ -233,7 +243,7 @@ class UtilsAuthService extends AppServiceBase {
* @param req * @param req
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async channelUserLogin(pobj,actionBody,req){ async channelUserLogin(pobj, actionBody, req) {
let opResult = system.getResultSuccess() let opResult = system.getResultSuccess()
let pin = actionBody.pin; let pin = actionBody.pin;
let result = await this.get360Token(); let result = await this.get360Token();
...@@ -251,19 +261,11 @@ class UtilsAuthService extends AppServiceBase { ...@@ -251,19 +261,11 @@ class UtilsAuthService extends AppServiceBase {
// } // }
//---渠道用户登录,有则返回userpin ,没有则注册用户并返回userpin //---渠道用户登录,有则返回userpin ,没有则注册用户并返回userpin
actionBody.channelUserId = pin; actionBody.channelUserId = pin;
let loginRt = await this.getLoginByUserName(pobj,actionBody); opResult = await this.getLoginByUserName(pobj, actionBody);
if (loginRt.status != 0 && loginRt.status != 2060) {
return loginRt;
}
opResult.data={ userpin : pobj.actionBody.userpin }
if (loginRt.status == 2060) {
opResult.msg = loginRt.msg;
opResult.data.userpin = loginRt.data.userpin;
}
return opResult; return opResult;
} }
async get360Token(){ async get360Token() {
let rtn = await this.execClient.exec360GetToken(settings.tokenUrl360()) let rtn = await this.execClient.exec360GetToken(settings.tokenUrl360())
if (!rtn || !rtn.stdout) { if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty"); return system.getResult(null, "restPost data is empty");
......
...@@ -279,16 +279,7 @@ class UtilsFeishuService { ...@@ -279,16 +279,7 @@ class UtilsFeishuService {
//渠道通过账户进行登录,有则返回用户信息,没有则创建用户------>供后端调用 //渠道通过账户进行登录,有则返回用户信息,没有则创建用户------>供后端调用
async getLoginByUserName(req, pobj) { async getLoginByUserName(req, pobj) {
pobj.actionBody.userpin = this.getUUID(); let opResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
var opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin });
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
return opResult; return opResult;
} }
} }
......
...@@ -1083,9 +1083,16 @@ class UtilsNeedService extends AppServiceBase { ...@@ -1083,9 +1083,16 @@ class UtilsNeedService extends AppServiceBase {
pobj.actionBody.channelUserId = needInfoResult.data.publishMobile; // 即:86_18512345678 pobj.actionBody.channelUserId = needInfoResult.data.publishMobile; // 即:86_18512345678
pobj.actionBody.userName = needInfoResult.data.publishMobile; pobj.actionBody.userName = needInfoResult.data.publishMobile;
pobj.actionBody.mobile = needInfoResult.data.publishMobile; pobj.actionBody.mobile = needInfoResult.data.publishMobile;
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID(); // pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();//采用jwt方式封装userpin
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody); var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
pobj.userInfo = tmpOpResult.data if (tmpOpResult.status != 0) {
return system.getResult(null, "创建用户信息失败");
}
pobj.userInfo = {
channel_userid: needInfoResult.data.publishMobile,
channel_username: needInfoResult.data.publishMobile,
mobile: needInfoResult.data.publishMobile
}
// 第三步 走addOrder流程 // 第三步 走addOrder流程
// var pobjStr = JSON.stringify(pobj); // var pobjStr = JSON.stringify(pobj);
// var qobj = JSON.parse(pobjStr); // var qobj = JSON.parse(pobjStr);
...@@ -1124,10 +1131,10 @@ class UtilsNeedService extends AppServiceBase { ...@@ -1124,10 +1131,10 @@ class UtilsNeedService extends AppServiceBase {
// var reqUrl = this.centerOrderUrl + "action/order/springBoard"; // var reqUrl = this.centerOrderUrl + "action/order/springBoard";
// qobj.actionBody.channelOrder.orderStatus = 2;// 2作为orderinfo的orderStatus的值。含义为已付款 // qobj.actionBody.channelOrder.orderStatus = 2;// 2作为orderinfo的orderStatus的值。含义为已付款
// var result = await this.restPostUrl(qobj, reqUrl); // var result = await this.restPostUrl(qobj, reqUrl);
pobj.actionBody.bizId = actionBody.bizId, pobj.actionBody.bizId = actionBody.bizId;
pobj.actionBody.userName = needInfoResult.data.publishName, pobj.actionBody.userName = needInfoResult.data.publishName;
pobj.actionBody.mobile = needInfoResult.data.publishMobile, pobj.actionBody.mobile = needInfoResult.data.publishMobile;
pobj.actionBody.orderNo = actionBody.bizId; pobj.actionBody.orderNo = actionBody.bizId;
pobj.actionBody.totalSum = productPriceResult.data.price; pobj.actionBody.totalSum = productPriceResult.data.price;
pobj.actionBody.orderPrice = productPriceResult.data.price; pobj.actionBody.orderPrice = productPriceResult.data.price;
pobj.actionBody.payTotalSum = productPriceResult.data.price; pobj.actionBody.payTotalSum = productPriceResult.data.price;
......
...@@ -46,9 +46,9 @@ class UtilsUcommuneService extends AppServiceBase { ...@@ -46,9 +46,9 @@ class UtilsUcommuneService extends AppServiceBase {
pobj.actionBody.nickName = result.data.name; pobj.actionBody.nickName = result.data.name;
pobj.actionBody.mobile = result.data.mobile; pobj.actionBody.mobile = result.data.mobile;
pobj.actionBody.headUrl = result.data.headImg; pobj.actionBody.headUrl = result.data.headImg;
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID(); // pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();//采用jwt方式封装userpin
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody); var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(req, pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) { if (tmpOpResult.status != 0) {
return tmpOpResult; return tmpOpResult;
} }
this.logCtl.info({ this.logCtl.info({
......
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