Commit a66321bf authored by mengwenhao's avatar mengwenhao

update: 更新请求代码

parent ec879c13
const { LOGIN_URI, API_INTERNAL_URI } = require("../config.js"); const { LOGIN_URI, API_INTERNAL_URI } = require("../config.js");
const req = require("../utils/request").httpReq; const req = require("../utils/request").httpReq;
/** exports.login = async ctx => {
* 用户登录校验,用于校验是否是公司员工, 目前使用pandora系统的登录验证 var url = `${LOGIN_URI}/api/v1/pandora/auth`;
*/ var opts = {
exports.login = async (ctx, next) => { url: url,
const url = `${LOGIN_URI}/api/v1/pandora/auth`;
const opts = {
url,
method: "POST", method: "POST",
json: true, json: true,
timeout: 8000,
body: ctx.request.body body: ctx.request.body
}; };
// ctx.body = await req(ctx, opts)
const userInfo = await req(ctx, opts);
// {
// type: 'Bearer',
// token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjIwNTc1OTMsImlhdCI6MTYyMjAxNDM5MywiaW5mbyI6eyJpZCI6IjczMjQ3MzQzOSIsImlzU3VwZXIiOnRydWUsIm5hbWUiOiLlkJXkvJ_mnJ0iLCJkZXBhcnRtZW50SWQiOiIxMzk4MzY4NDEwIiwicGVybWlzc2lvbnMiOltdLCJzZWN1cml0eSI6ZmFsc2UsImFjdGl2ZSI6dHJ1ZX19.65357uakQSUaWS95c16nQgj9JkBmKGvwGJW4C4hEjWY',
// auth: {
// id: '732473439',
// isSuper: true,
// name: '吕伟朝',
// departmentId: '1398368410',
// permissions: [],
// security: false,
// active: true
// },
// userInfo: {
// id: '732473439',
// isSuper: true,
// name: '吕伟朝',
// displayName: '吕伟朝',
// email: 'lvweichao@yidian-inc.com',
// departmentId: '1398368410',
// department: { id: '1398368410', name: '平台产品研发部' },
// property: 'yidian',
// description: '',
// createdAt: '2020-07-31T08:24:05Z',
// lastUpdate: '2020-08-07T07:18:59.194Z',
// active: true
// }
// }
if (typeof userInfo === "string") {
ctx.body = { status: "fail", message: userInfo };
}
console.log(43444, userInfo, typeof userInfo); console.log(43444, userInfo, typeof userInfo);
// if userInfo // if userInfo
......
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