mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-08 00:50:28 +08:00
fix: redirect for non-built-in app logout (#587)
Signed-off-by: Steve0x2a <stevesough@gmail.com>
This commit is contained in:
@ -225,10 +225,15 @@ func (c *ApiController) Logout() {
|
|||||||
user := c.GetSessionUsername()
|
user := c.GetSessionUsername()
|
||||||
util.LogInfo(c.Ctx, "API: [%s] logged out", user)
|
util.LogInfo(c.Ctx, "API: [%s] logged out", user)
|
||||||
|
|
||||||
|
application := c.GetSessionApplication()
|
||||||
c.SetSessionUsername("")
|
c.SetSessionUsername("")
|
||||||
c.SetSessionData(nil)
|
c.SetSessionData(nil)
|
||||||
|
|
||||||
c.ResponseOk(user)
|
if application == nil || application.Name == "app-built-in" || application.HomepageUrl == "" {
|
||||||
|
c.ResponseOk(user)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.ResponseOk(user, application.HomepageUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccount
|
// GetAccount
|
||||||
|
@ -72,6 +72,15 @@ func (c *ApiController) GetSessionUsername() string {
|
|||||||
return user.(string)
|
return user.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ApiController) GetSessionApplication() *object.Application {
|
||||||
|
clientId := c.GetSession("aud")
|
||||||
|
if clientId == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
application := object.GetApplicationByClientId(clientId.(string))
|
||||||
|
return application
|
||||||
|
}
|
||||||
|
|
||||||
func (c *ApiController) GetSessionOidc() (string, string) {
|
func (c *ApiController) GetSessionOidc() (string, string) {
|
||||||
sessionData := c.GetSessionData()
|
sessionData := c.GetSessionData()
|
||||||
if sessionData != nil &&
|
if sessionData != nil &&
|
||||||
|
@ -235,8 +235,12 @@ class App extends Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Setting.showMessage("success", `Logged out successfully`);
|
Setting.showMessage("success", `Logged out successfully`);
|
||||||
|
let redirectUri = res.data2;
|
||||||
Setting.goToLinkSoft(this, "/");
|
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
|
||||||
|
Setting.goToLink(redirectUri);
|
||||||
|
}else{
|
||||||
|
Setting.goToLinkSoft(this, "/");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", `Failed to log out: ${res.msg}`);
|
Setting.showMessage("error", `Failed to log out: ${res.msg}`);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,10 @@ class PromptPage extends React.Component {
|
|||||||
if (res.status === 'ok') {
|
if (res.status === 'ok') {
|
||||||
this.onUpdateAccount(null);
|
this.onUpdateAccount(null);
|
||||||
|
|
||||||
const redirectUrl = this.getRedirectUrl();
|
let redirectUrl = this.getRedirectUrl();
|
||||||
|
if (redirectUrl === "") {
|
||||||
|
redirectUrl = res.data2
|
||||||
|
}
|
||||||
if (redirectUrl !== "") {
|
if (redirectUrl !== "") {
|
||||||
Setting.goToLink(redirectUrl);
|
Setting.goToLink(redirectUrl);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user