feat: fix incorrect CAS url concatenation (#795)

* fix: fix incorrect cas url concatenation

* Update LoginPage.js

Co-authored-by: Gucheng <85475922+nomeguy@users.noreply.github.com>
This commit is contained in:
Товарищ программист
2022-06-14 21:51:40 +08:00
committed by GitHub
parent 15a6fd2b52
commit ff94e5164a

View File

@ -144,43 +144,44 @@ class LoginPage extends React.Component {
const application = this.getApplicationObj(); const application = this.getApplicationObj();
const ths = this; const ths = this;
//here we are supposed to judge whether casdoor is working as a oauth server or CAS server // here we are supposed to determine whether Casdoor is working as an OAuth server or CAS server
if (this.state.type === "cas") { if (this.state.type === "cas") {
//cas // CAS
const casParams = Util.getCasParameters() const casParams = Util.getCasParameters();
values["type"] = this.state.type; values["type"] = this.state.type;
AuthBackend.loginCas(values, casParams).then((res) => { AuthBackend.loginCas(values, casParams).then((res) => {
if (res.status === 'ok') { if (res.status === 'ok') {
let msg = "Logged in successfully. " let msg = "Logged in successfully. ";
if (casParams.service === "") { if (casParams.service === "") {
//If service was not specified, CAS MUST display a message notifying the client that it has successfully initiated a single sign-on session. // If service was not specified, Casdoor must display a message notifying the client that it has successfully initiated a single sign-on session.
msg += "Now you can visit apps protected by casdoor." msg += "Now you can visit apps protected by Casdoor.";
} }
Util.showMessage("success", msg); Util.showMessage("success", msg);
if (casParams.service !== "") {
let st = res.data
window.location.href = casParams.service + "?ticket=" + st
}
if (casParams.service !== "") {
let st = res.data;
let newUrl = new URL(casParams.service);
newUrl.searchParams.append("ticket", st);
window.location.href = newUrl.toString();
}
} else { } else {
Util.showMessage("error", `Failed to log in: ${res.msg}`); Util.showMessage("error", `Failed to log in: ${res.msg}`);
} }
}) })
} else { } else {
//oauth // OAuth
const oAuthParams = Util.getOAuthGetParameters(); const oAuthParams = Util.getOAuthGetParameters();
if (oAuthParams !== null && oAuthParams.responseType != null && oAuthParams.responseType !== "") { if (oAuthParams !== null && oAuthParams.responseType != null && oAuthParams.responseType !== "") {
values["type"] = oAuthParams.responseType values["type"] = oAuthParams.responseType;
}else{ } else {
values["type"] = this.state.type; values["type"] = this.state.type;
} }
values["phonePrefix"] = this.getApplicationObj()?.organizationObj.phonePrefix; values["phonePrefix"] = this.getApplicationObj()?.organizationObj.phonePrefix;
if (oAuthParams !== null){ if (oAuthParams !== null) {
values["samlRequest"] = oAuthParams.samlRequest; values["samlRequest"] = oAuthParams.samlRequest;
} }
if (values["samlRequest"] != null && values["samlRequest"] !== "") { if (values["samlRequest"] != null && values["samlRequest"] !== "") {
values["type"] = "saml"; values["type"] = "saml";
} }