|
@@ -4,6 +4,7 @@ const assert = require('assert');
|
|
|
const uuid = require('uuid');
|
|
|
const random = require('string-random');
|
|
|
const crypto = require('crypto');
|
|
|
+const urljoin = require('url-join');
|
|
|
const _ = require('lodash');
|
|
|
const moment = require('moment');
|
|
|
const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
@@ -51,7 +52,6 @@ class WeixinAuthService extends AxiosService {
|
|
|
const req = this.ctx.curl(url, { method: 'GET' });
|
|
|
if (req.status !== 200) throw new BusinessError(ErrorCode.SERVICE_FAULT, 'openid获取失败');
|
|
|
const openid = _.get(req, 'data.openid');
|
|
|
- console.log(`openid=>${openid}`);
|
|
|
if (!openid) {
|
|
|
this.ctx.logger.error(JSON.stringify(req.data));
|
|
|
throw new BusinessError(ErrorCode.SERVICE_FAULT, '未获取到openid');
|
|
@@ -60,7 +60,8 @@ class WeixinAuthService extends AxiosService {
|
|
|
const key = `${this.prefix}${state}`;
|
|
|
let fqueries = await this.app.redis.get(key);
|
|
|
if (fqueries)fqueries = JSON.parse(fqueries);
|
|
|
- const { redirect_uri } = fqueries;
|
|
|
+ let { redirect_uri } = fqueries;
|
|
|
+ redirect_uri = urljoin(redirect_uri, `?openid=${openid}`);
|
|
|
this.ctx.redirect(redirect_uri);
|
|
|
}
|
|
|
/**
|