Commit 3ee3f957 by 宋毅

tj

parent 3d8e2d0a
......@@ -43,8 +43,8 @@ class AccessAuthAPI extends APIBase {
action_body.appInfo = req.app;
var opStr = action_body.userName || action_body.mobile;
var encryptStrResult = await this.toolSve.encryptStr(req.app, opStr);
if(encryptStrResult.status==0){
encryptStrResult.data= encodeURIComponent(encryptStrResult.data);
if (encryptStrResult.status == 0) {
encryptStrResult.data = encodeURIComponent(encryptStrResult.data);
}
switch (action_type) {
// sy
......@@ -81,6 +81,12 @@ class AccessAuthAPI extends APIBase {
return system.getResultSuccess({ userpin: userpin, channelUserId: encryptStrResult.data, userName: opStr })
}
break;
case "logout":
opResult = await this.opPlatformUtils.userLogout(action_body);
break;
case "putUserPwdByMobile":
opResult = await this.opPlatformUtils.putUserPwdByMobile(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -11,6 +11,8 @@ class OpPlatformUtils {
this.loginUrl = settings.paasUrl() + "api/auth/accessAuth/loginByMd5Password";
this.authByCodeUrl = settings.paasUrl() + "api/auth/accessAuth/authByCode";
this.loginByVCodeUrl = settings.paasUrl() + "api/auth/accessAuth/loginByVCode";
this.modiPasswordByMobileUrl = settings.paasUrl() + "api/auth/accessAuth/modiPasswordByMobile";
this.exTime = 2 * 3600;//缓存过期时间,2小时
}
getUUID() {
......@@ -86,6 +88,22 @@ class OpPlatformUtils {
}
return system.getResultSuccess();
}
async modiPasswordByMobile(mobile, vcode, newPwd, appKey, secret) {
var reqApiAccessKey = await this.getReqApiAccessKey(appKey, secret);
if (reqApiAccessKey.status != 0) {
return reqApiAccessKey;
}
var param = { mobile: mobile, vcode: vcode, newPwd: newPwd }
//按照访问token
var restResult = await this.restClient.execPostWithAK(
param,
this.modiPasswordByMobileUrl, reqApiAccessKey.data.accessKey);
if (restResult.status != 0 || !restResult.data) {
return system.getResult(null, restResult.msg);
}
return system.getResultSuccess();
}
/**
* 用户登录
* @param {*} userName 用户名
......@@ -243,6 +261,34 @@ class OpPlatformUtils {
var acckapp = await this.fetchVCode(actionBody.mobile, actionBody.appInfo.uappKey, actionBody.appInfo.appSecret);
return acckapp;
}
async putUserPwdByMobile(actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "pobj.mobile can not be empty !");
}
if (!actionBody.vcode) {
return system.getResult(null, "pobj.vcode can not be empty !");
}
if (!actionBody.newPwd) {
return system.getResult(null, "pobj.newPwd can not be empty !");
}
if (!actionBody.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !");
}
var acckapp = await this.modiPasswordByMobile(actionBody.mobile, actionBody.vcode, actionBody.newPwd, actionBody.appInfo.uappKey, actionBody.appInfo.appSecret);
if (acckapp.status == 0 && actionBody.userpin) {
this.userLogout(actionBody);
}
return acckapp;
}
async userLogout(actionBody) {
if (!actionBody.userpin) {
return system.getResult(null, "pobj.userpin can not be empty !");
}
var cacheManager = system.getObject("db.common.cacheManager");
await cacheManager["AppUserPinByLoginVcodeCache"].invalidate(actionBody.userpin);
await cacheManager["AppUserPinByLoginPwdCache"].invalidate(actionBody.userpin);
return system.getResultSuccess();
}
}
module.exports = OpPlatformUtils;
......@@ -3,6 +3,8 @@
1. [密码登录](#pwdLogin)
1. [验证码登录](#userPinByLgoinVcode)
1. [用户注册](#userPinByRegister)
1. [按照手机号和验证码修改密码](#putUserPwdByMobile)
1. [退出](#logout)
## **<a name="smsCode"> 短信验证码</a>**
......@@ -120,3 +122,55 @@
}
```
## **<a name="putUserPwdByMobile"> 按照手机号和验证码修改密码</a>**
[返回到目录](#menu)
##### URL
[/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:putUserPwdByMobile
``` javascript
{
"mobile":"15010929366", // Y 手机号
"vcode":"593555", // Y 验证码
"newPwd":"123456" // Y 新密码
"userpin":"79009f97cebf4866834ee9e863d5f9b8" // N 用户登录凭证key
}
```
#### 返回结果
``` javascript
{
"status": 0,// 0为成功,2030为验证码错误,否则失败
"msg": "success",
"data": null,
"requestId": "1b12b0e9c190436da000386ddf693c8f"
}
```
## **<a name="logout"> 退出</a>**
[返回到目录](#menu)
##### URL
[/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:logout
``` javascript
{
"userpin":"15010929366" // Y 用户登录凭证key
}
```
#### 返回结果
``` javascript
{
"status": 0,// 0为成功,否则失败
"msg": "success",
"data": null,
"requestId": "1b12b0e9c190436da000386ddf693c8f"
}
```
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