Skip to content

Commit

Permalink
fix: callback url param missing (casdoor#583)
Browse files Browse the repository at this point in the history
Signed-off-by: Yixiang Zhao <[email protected]>
  • Loading branch information
seriouszyx authored Mar 19, 2022
1 parent 8080927 commit dcd6328
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions web/src/auth/AuthCallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class AuthCallback extends React.Component {
method: method,
};
const oAuthParams = Util.getOAuthGetParameters(innerParams);
const concatChar = oAuthParams.redirectUri.indexOf('?') === -1 ? '?' : '&';
AuthBackend.login(body, oAuthParams)
.then((res) => {
if (res.status === 'ok') {
Expand All @@ -118,11 +119,11 @@ class AuthCallback extends React.Component {
Setting.goToLink(link);
} else if (responseType === "code") {
const code = res.data;
Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
// Util.showMessage("success", `Authorization code: ${res.data}`);
} else if (responseType === "token" || responseType === "id_token"){
const token = res.data;
Setting.goToLink(`${oAuthParams.redirectUri}?${responseType}=${token}&state=${oAuthParams.state}&token_type=bearer`);
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}${responseType}=${token}&state=${oAuthParams.state}&token_type=bearer`);
} else if (responseType === "link") {
const from = innerParams.get("from");
Setting.goToLinkSoft(this, from);
Expand Down
5 changes: 3 additions & 2 deletions web/src/auth/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class LoginPage extends React.Component {
Setting.goToLink(link);
} else if (responseType === "code") {
const code = res.data;
const concatChar = oAuthParams.redirectUri.indexOf('?') === -1 ? '?' : '&';

if (Setting.hasPromptPage(application)) {
AuthBackend.getAccount("")
Expand All @@ -150,7 +151,7 @@ class LoginPage extends React.Component {
this.onUpdateAccount(account);

if (Setting.isPromptAnswered(account, application)) {
Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
} else {
Setting.goToLinkSoft(ths, `/prompt/${application.name}?redirectUri=${oAuthParams.redirectUri}&code=${code}&state=${oAuthParams.state}`);
}
Expand All @@ -159,7 +160,7 @@ class LoginPage extends React.Component {
}
});
} else {
Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);
Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`);
}

// Util.showMessage("success", `Authorization code: ${res.data}`);
Expand Down

0 comments on commit dcd6328

Please sign in to comment.