Improve OAuth params.

This commit is contained in:
Yang Luo
2021-08-01 11:20:06 +08:00
parent 3be7d3b273
commit 629ae5a54b
6 changed files with 338 additions and 12 deletions

View File

@ -38,6 +38,12 @@ export function getEmailAndPhone(values) {
}
function oAuthParamsToQuery(oAuthParams) {
// login
if (oAuthParams === null) {
return "";
}
// code
return `?clientId=${oAuthParams.clientId}&responseType=${oAuthParams.responseType}&redirectUri=${oAuthParams.redirectUri}&scope=${oAuthParams.scope}&state=${oAuthParams.state}`;
}

View File

@ -68,7 +68,11 @@ class AuthCallback extends React.Component {
UNSAFE_componentWillMount() {
const params = new URLSearchParams(this.props.location.search);
const code = params.get("code");
let code = params.get("code");
// WeCom returns "auth_code=xxx" instead of "code=xxx"
if (code === null) {
code = params.get("auth_code");
}
const innerParams = this.getInnerParams();
const applicationName = innerParams.get("application");

View File

@ -82,9 +82,12 @@ export function getOAuthGetParameters(params) {
const redirectUri = queries.get("redirect_uri");
const scope = queries.get("scope");
const state = queries.get("state");
if (clientId === undefined) {
if (clientId === undefined || clientId === null) {
// login
return null;
} else {
// code
return {
clientId: clientId,
responseType: responseType,