Skip to content

Commit

Permalink
feat: fix incorrect CAS url concatenation (casdoor#795)
Browse files Browse the repository at this point in the history
* fix: fix incorrect cas url concatenation

* Update LoginPage.js

Co-authored-by: Gucheng <[email protected]>
  • Loading branch information
ComradeProgrammer and nomeguy authored Jun 14, 2022
1 parent 15a6fd2 commit ff94e51
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions web/src/auth/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,47 +144,48 @@ class LoginPage extends React.Component {
const application = this.getApplicationObj();
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") {
//cas
const casParams = Util.getCasParameters()
// CAS
const casParams = Util.getCasParameters();
values["type"] = this.state.type;
AuthBackend.loginCas(values, casParams).then((res) => {
if (res.status === 'ok') {
let msg = "Logged in successfully. "
let msg = "Logged in successfully. ";
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.
msg += "Now you can visit apps protected by casdoor."
// 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.";
}
Util.showMessage("success", msg);

if (casParams.service !== "") {
let st = res.data
window.location.href = casParams.service + "?ticket=" + st
let st = res.data;
let newUrl = new URL(casParams.service);
newUrl.searchParams.append("ticket", st);
window.location.href = newUrl.toString();
}

} else {
Util.showMessage("error", `Failed to log in: ${res.msg}`);
}
})
} else {
//oauth
// OAuth
const oAuthParams = Util.getOAuthGetParameters();
if (oAuthParams !== null && oAuthParams.responseType != null && oAuthParams.responseType !== "") {
values["type"] = oAuthParams.responseType
}else{
values["type"] = oAuthParams.responseType;
} else {
values["type"] = this.state.type;
}
values["phonePrefix"] = this.getApplicationObj()?.organizationObj.phonePrefix;

if (oAuthParams !== null){
if (oAuthParams !== null) {
values["samlRequest"] = oAuthParams.samlRequest;
}



if (values["samlRequest"] != null && values["samlRequest"] !== "") {
values["type"] = "saml";
}

AuthBackend.login(values, oAuthParams)
.then((res) => {
if (res.status === 'ok') {
Expand Down

0 comments on commit ff94e51

Please sign in to comment.