mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
feat: append logo url to cookie (#3507)
This commit is contained in:
@ -30,7 +30,7 @@ func appendThemeCookie(ctx *context.Context, urlPath string) error {
|
||||
return err
|
||||
}
|
||||
if application.ThemeData != nil {
|
||||
return setThemeDataCookie(ctx, application.ThemeData)
|
||||
return setThemeDataCookie(ctx, application.ThemeData, application.Logo)
|
||||
}
|
||||
organization := application.OrganizationObj
|
||||
if organization == nil {
|
||||
@ -40,7 +40,7 @@ func appendThemeCookie(ctx *context.Context, urlPath string) error {
|
||||
}
|
||||
}
|
||||
if organization != nil {
|
||||
return setThemeDataCookie(ctx, organization.ThemeData)
|
||||
return setThemeDataCookie(ctx, organization.ThemeData, organization.Logo)
|
||||
}
|
||||
} else if strings.HasPrefix(urlPath, "/login/oauth/authorize") {
|
||||
clientId := ctx.Input.Query("client_id")
|
||||
@ -57,10 +57,10 @@ func appendThemeCookie(ctx *context.Context, urlPath string) error {
|
||||
return err
|
||||
}
|
||||
if application.ThemeData != nil {
|
||||
return setThemeDataCookie(ctx, application.ThemeData)
|
||||
return setThemeDataCookie(ctx, application.ThemeData, application.Logo)
|
||||
}
|
||||
if organization != nil {
|
||||
return setThemeDataCookie(ctx, organization.ThemeData)
|
||||
return setThemeDataCookie(ctx, organization.ThemeData, organization.Logo)
|
||||
}
|
||||
}
|
||||
} else if strings.HasPrefix(urlPath, "/login/") {
|
||||
@ -71,7 +71,7 @@ func appendThemeCookie(ctx *context.Context, urlPath string) error {
|
||||
return err
|
||||
}
|
||||
if application.ThemeData != nil {
|
||||
return setThemeDataCookie(ctx, application.ThemeData)
|
||||
return setThemeDataCookie(ctx, application.ThemeData, application.Logo)
|
||||
}
|
||||
organization := application.OrganizationObj
|
||||
if organization == nil {
|
||||
@ -81,7 +81,7 @@ func appendThemeCookie(ctx *context.Context, urlPath string) error {
|
||||
}
|
||||
}
|
||||
if organization != nil {
|
||||
return setThemeDataCookie(ctx, organization.ThemeData)
|
||||
return setThemeDataCookie(ctx, organization.ThemeData, organization.Logo)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,11 +89,12 @@ func appendThemeCookie(ctx *context.Context, urlPath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func setThemeDataCookie(ctx *context.Context, themeData *object.ThemeData) error {
|
||||
func setThemeDataCookie(ctx *context.Context, themeData *object.ThemeData, logoUrl string) error {
|
||||
themeDataString, err := json.Marshal(themeData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.SetCookie("organizationTheme", string(themeDataString))
|
||||
ctx.SetCookie("organizationLogo", logoUrl)
|
||||
return nil
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ class App extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
renderFooter() {
|
||||
renderFooter(logo) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
{!this.state.account ? null : <div style={{display: "none"}} id="CasdoorApplicationName" value={this.state.account.signupApplication} />}
|
||||
@ -288,7 +288,7 @@ class App extends Component {
|
||||
: (
|
||||
Conf.CustomFooter !== null ? Conf.CustomFooter : (
|
||||
<React.Fragment>
|
||||
Powered by <a target="_blank" href="https://casdoor.org" rel="noreferrer"><img style={{paddingBottom: "3px"}} height={"20px"} alt={"Casdoor"} src={this.state.logo} /></a>
|
||||
Powered by <a target="_blank" href="https://casdoor.org" rel="noreferrer"><img style={{paddingBottom: "3px"}} height={"20px"} alt={"Casdoor"} src={logo ?? this.state.logo} /></a>
|
||||
</React.Fragment>
|
||||
)
|
||||
)
|
||||
@ -362,11 +362,15 @@ class App extends Component {
|
||||
renderPage() {
|
||||
if (this.isDoorPages()) {
|
||||
let themeData = this.state.themeData;
|
||||
let logo = this.state.logo;
|
||||
if (this.state.organization === undefined) {
|
||||
const curCookie = Cookie.parse(document.cookie);
|
||||
if (curCookie["organizationTheme"] && curCookie["organizationTheme"] !== "null") {
|
||||
themeData = JSON.parse(curCookie["organizationTheme"]);
|
||||
}
|
||||
if (curCookie["organizationLogo"] && curCookie["organizationLogo"] !== "") {
|
||||
logo = curCookie["organizationLogo"];
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@ -410,7 +414,7 @@ class App extends Component {
|
||||
}
|
||||
</Content>
|
||||
{
|
||||
this.renderFooter()
|
||||
this.renderFooter(logo)
|
||||
}
|
||||
{
|
||||
this.renderAiAssistant()
|
||||
|
Reference in New Issue
Block a user