mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
150116a172
* Implement an automatic theme The "auto" theme will automatically switch between "dark" and "light" depending on user preference. This allows for automatic dark mode. * fix(configuration): allow the "auto" theme when validating The new theme "auto" was not allowed to be used in a configuration file. * docs: clarify what critera controls the automatic theme How the "auto" theme functioned was unclear. * docs: typeset themes as code * fix(web): apply useEffector to media query watch * docs: add technical details * fix(configuration): resolve merge conflicts
22 lines
585 B
Go
22 lines
585 B
Go
package validator
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
)
|
|
|
|
// ValidateTheme validates and update Theme configuration.
|
|
func ValidateTheme(configuration *schema.Configuration, validator *schema.StructValidator) {
|
|
if configuration.Theme == "" {
|
|
configuration.Theme = "light"
|
|
}
|
|
|
|
validThemes := regexp.MustCompile("light|dark|grey|auto")
|
|
|
|
if !validThemes.MatchString(configuration.Theme) {
|
|
validator.Push(fmt.Errorf("Theme: %s is not valid, valid themes are: \"light\", \"dark\", \"grey\" or \"auto\"", configuration.Theme))
|
|
}
|
|
}
|