mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 18:54:03 +08:00
Add getRawGetParameter()
This commit is contained in:
parent
225e9cf70a
commit
d29fc88d68
@ -80,9 +80,9 @@ export function getCasParameters(params) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRedirectUri() {
|
function getRawGetParameter(key) {
|
||||||
const fullUrl = window.location.href;
|
const fullUrl = window.location.href;
|
||||||
const token = fullUrl.split("redirect_uri=")[1];
|
const token = fullUrl.split(`${key}=`)[1];
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -101,18 +101,24 @@ export function getOAuthGetParameters(params) {
|
|||||||
const clientId = getRefinedValue(queries.get("client_id"));
|
const clientId = getRefinedValue(queries.get("client_id"));
|
||||||
const responseType = getRefinedValue(queries.get("response_type"));
|
const responseType = getRefinedValue(queries.get("response_type"));
|
||||||
|
|
||||||
let redirectUri = getRedirectUri();
|
let redirectUri = getRawGetParameter("redirect_uri");
|
||||||
if (redirectUri === "") {
|
if (redirectUri === "") {
|
||||||
redirectUri = getRefinedValue(queries.get("redirect_uri"));
|
redirectUri = getRefinedValue(queries.get("redirect_uri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const scope = getRefinedValue(queries.get("scope"));
|
let scope = getRefinedValue(queries.get("scope"));
|
||||||
|
if (redirectUri.includes("#") && scope === "") {
|
||||||
|
scope = getRawGetParameter("scope");
|
||||||
|
}
|
||||||
|
|
||||||
let state = getRefinedValue(queries.get("state"));
|
let state = getRefinedValue(queries.get("state"));
|
||||||
if (state.startsWith("/auth/oauth2/login.php?wantsurl=")) {
|
if (state.startsWith("/auth/oauth2/login.php?wantsurl=")) {
|
||||||
// state contains URL param encoding for Moodle, URLSearchParams automatically decoded it, so here encode it again
|
// state contains URL param encoding for Moodle, URLSearchParams automatically decoded it, so here encode it again
|
||||||
state = encodeURIComponent(state);
|
state = encodeURIComponent(state);
|
||||||
}
|
}
|
||||||
|
if (redirectUri.includes("#") && state === "") {
|
||||||
|
state = getRawGetParameter("state");
|
||||||
|
}
|
||||||
|
|
||||||
const nonce = getRefinedValue(queries.get("nonce"));
|
const nonce = getRefinedValue(queries.get("nonce"));
|
||||||
const challengeMethod = getRefinedValue(queries.get("code_challenge_method"));
|
const challengeMethod = getRefinedValue(queries.get("code_challenge_method"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user