mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
Improve OAuth params.
This commit is contained in:
@ -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}`;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user