mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +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 token = fullUrl.split("redirect_uri=")[1];
|
||||
const token = fullUrl.split(`${key}=`)[1];
|
||||
if (!token) {
|
||||
return "";
|
||||
}
|
||||
@ -101,18 +101,24 @@ export function getOAuthGetParameters(params) {
|
||||
const clientId = getRefinedValue(queries.get("client_id"));
|
||||
const responseType = getRefinedValue(queries.get("response_type"));
|
||||
|
||||
let redirectUri = getRedirectUri();
|
||||
let redirectUri = getRawGetParameter("redirect_uri");
|
||||
if (redirectUri === "") {
|
||||
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"));
|
||||
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 = encodeURIComponent(state);
|
||||
}
|
||||
if (redirectUri.includes("#") && state === "") {
|
||||
state = getRawGetParameter("state");
|
||||
}
|
||||
|
||||
const nonce = getRefinedValue(queries.get("nonce"));
|
||||
const challengeMethod = getRefinedValue(queries.get("code_challenge_method"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user