MCPcopy
hub / github.com/YMFE/yapi / updateToken

Method updateToken

server/controllers/project.js:1034–1056  ·  view source on GitHub ↗

* 更新token数据 * @interface /project/update_token * @method GET * @category project * @foldnumber 10 * @param {Number} id 项目id,不能为空 * @param {String} q * @return {Object}

(ctx)

Source from the content-addressed store, hash-verified

1032 * @return {Object}
1033 */
1034 async updateToken(ctx) {
1035 try {
1036 let project_id = ctx.params.project_id;
1037 let data = await this.tokenModel.get(project_id);
1038 let token, result;
1039 if (data && data.token) {
1040 let passsalt = yapi.commons.randStr();
1041 token = sha('sha1')
1042 .update(passsalt)
1043 .digest('hex')
1044 .substr(0, 20);
1045 result = await this.tokenModel.up(project_id, token);
1046 token = getToken(token);
1047 result.token = token;
1048 } else {
1049 ctx.body = yapi.commons.resReturn(null, 402, '没有查到token信息');
1050 }
1051
1052 ctx.body = yapi.commons.resReturn(result);
1053 } catch (err) {
1054 ctx.body = yapi.commons.resReturn(null, 402, err.message);
1055 }
1056 }
1057
1058 /**
1059 * 模糊搜索项目名称或者分组名称或接口名称

Callers 2

onOkMethod · 0.80
tFunction · 0.80

Calls 4

getTokenFunction · 0.85
getMethod · 0.45
updateMethod · 0.45
upMethod · 0.45

Tested by

no test coverage detected