Stop adding .v2 to default theme if set in server config

Closes #15392
This commit is contained in:
stianst 2022-11-10 05:39:20 -05:00 committed by Pedro Igor
parent ebc91f6369
commit eb17157e44
2 changed files with 16 additions and 9 deletions

View file

@ -19,7 +19,6 @@ package org.keycloak.theme;
import org.keycloak.Config;
import org.keycloak.common.Profile;
import org.keycloak.common.Version;
import org.keycloak.provider.Provider;
/**
@ -27,6 +26,9 @@ import org.keycloak.provider.Provider;
*/
public interface ThemeSelectorProvider extends Provider {
String DEFAULT = "keycloak";
String DEFAULT_V2 = "keycloak.v2";
/**
* Return the theme name to use for the specified type
*
@ -36,13 +38,20 @@ public interface ThemeSelectorProvider extends Provider {
String getThemeName(Theme.Type type);
default String getDefaultThemeName(Theme.Type type) {
String name = Config.scope("theme").get("default", Version.NAME.toLowerCase());
if ((type == Theme.Type.ACCOUNT) && Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2)) {
name = name.concat(".v2");
} else if ((type == Theme.Type.ADMIN) && Profile.isFeatureEnabled(Profile.Feature.ADMIN2)) {
name = name.concat(".v2");
}
String name = Config.scope("theme").get("default");
if (name != null && !name.isEmpty()) {
return name;
}
if ((type == Theme.Type.ACCOUNT) && Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2)) {
return DEFAULT_V2;
}
if ((type == Theme.Type.ADMIN) && Profile.isFeatureEnabled(Profile.Feature.ADMIN2)) {
return DEFAULT_V2;
}
return DEFAULT;
}
}

View file

@ -1,8 +1,6 @@
package org.keycloak.theme;
import org.keycloak.Config;
import org.keycloak.common.Profile;
import org.keycloak.common.Version;
import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession;