Fix bug in Casdoor's own 3rd-party login.

This commit is contained in:
Yang Luo 2021-05-01 22:27:20 +08:00
parent 0f7cd56441
commit d509c61816
2 changed files with 8 additions and 2 deletions

View File

@ -31,7 +31,7 @@ type Application struct {
Organization string `xorm:"varchar(100)" json:"organization"` Organization string `xorm:"varchar(100)" json:"organization"`
EnablePassword bool `json:"enablePassword"` EnablePassword bool `json:"enablePassword"`
EnableSignUp bool `json:"enableSignUp"` EnableSignUp bool `json:"enableSignUp"`
Providers []string `xorm:"varchar(100)" json:"providers"` Providers []string `xorm:"varchar(1000)" json:"providers"`
ProviderObjs []*Provider `xorm:"-" json:"providerObjs"` ProviderObjs []*Provider `xorm:"-" json:"providerObjs"`
OrganizationObj *Organization `xorm:"-" json:"organizationObj"` OrganizationObj *Organization `xorm:"-" json:"organizationObj"`

View File

@ -46,6 +46,11 @@ class AuthCallback extends React.Component {
const method = innerParams.get("method"); const method = innerParams.get("method");
if (method === "signup") { if (method === "signup") {
const realRedirectUri = innerParams.get("redirect_uri"); const realRedirectUri = innerParams.get("redirect_uri");
// Casdoor's own login page, so "code" is not necessary
if (realRedirectUri === null) {
return "login";
}
const realRedirectUrl = new URL(realRedirectUri).origin; const realRedirectUrl = new URL(realRedirectUri).origin;
// For Casdoor itself, we use "login" directly // For Casdoor itself, we use "login" directly
@ -85,7 +90,8 @@ class AuthCallback extends React.Component {
const responseType = this.getResponseType(); const responseType = this.getResponseType();
if (responseType === "login") { if (responseType === "login") {
Util.showMessage("success", `Logged in successfully`); Util.showMessage("success", `Logged in successfully`);
Setting.goToLinkSoft(this, "/"); // Setting.goToLinkSoft(this, "/");
Setting.goToLink("/");
} else if (responseType === "code") { } else if (responseType === "code") {
const code = res.data; const code = res.data;
Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`); Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);