mirror of
				https://github.com/steveiliop56/tinyauth.git
				synced 2025-10-31 06:05:43 +00:00 
			
		
		
		
	feat: custom background image config option
This commit is contained in:
		| @@ -28,3 +28,5 @@ LOGIN_MAX_RETRIES=5 | |||||||
| LOG_LEVEL=0 | LOG_LEVEL=0 | ||||||
| APP_TITLE=Tinyauth SSO | APP_TITLE=Tinyauth SSO | ||||||
| FORGOT_PASSWORD_MESSAGE=Some message about resetting the password | FORGOT_PASSWORD_MESSAGE=Some message about resetting the password | ||||||
|  | OAUTH_AUTO_REDIRECT=none | ||||||
|  | BACKGROUND_IMAGE=some_image_url | ||||||
| @@ -91,6 +91,7 @@ var rootCmd = &cobra.Command{ | |||||||
| 			CookieSecure:          config.CookieSecure, | 			CookieSecure:          config.CookieSecure, | ||||||
| 			Domain:                domain, | 			Domain:                domain, | ||||||
| 			ForgotPasswordMessage: config.FogotPasswordMessage, | 			ForgotPasswordMessage: config.FogotPasswordMessage, | ||||||
|  | 			BackgroundImage:       config.BackgroundImage, | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Create api config | 		// Create api config | ||||||
| @@ -198,6 +199,7 @@ func init() { | |||||||
| 	rootCmd.Flags().Int("log-level", 1, "Log level.") | 	rootCmd.Flags().Int("log-level", 1, "Log level.") | ||||||
| 	rootCmd.Flags().String("app-title", "Tinyauth", "Title of the app.") | 	rootCmd.Flags().String("app-title", "Tinyauth", "Title of the app.") | ||||||
| 	rootCmd.Flags().String("forgot-password-message", "You can reset your password by changing the `USERS` environment variable.", "Message to show on the forgot password page.") | 	rootCmd.Flags().String("forgot-password-message", "You can reset your password by changing the `USERS` environment variable.", "Message to show on the forgot password page.") | ||||||
|  | 	rootCmd.Flags().String("background-image", "/background.jpg", "Background image URL for the login page.") | ||||||
|  |  | ||||||
| 	// Bind flags to environment | 	// Bind flags to environment | ||||||
| 	viper.BindEnv("port", "PORT") | 	viper.BindEnv("port", "PORT") | ||||||
| @@ -230,6 +232,7 @@ func init() { | |||||||
| 	viper.BindEnv("login-timeout", "LOGIN_TIMEOUT") | 	viper.BindEnv("login-timeout", "LOGIN_TIMEOUT") | ||||||
| 	viper.BindEnv("login-max-retries", "LOGIN_MAX_RETRIES") | 	viper.BindEnv("login-max-retries", "LOGIN_MAX_RETRIES") | ||||||
| 	viper.BindEnv("forgot-password-message", "FORGOT_PASSWORD_MESSAGE") | 	viper.BindEnv("forgot-password-message", "FORGOT_PASSWORD_MESSAGE") | ||||||
|  | 	viper.BindEnv("background-image", "BACKGROUND_IMAGE") | ||||||
|  |  | ||||||
| 	// Bind flags to viper | 	// Bind flags to viper | ||||||
| 	viper.BindPFlags(rootCmd.Flags()) | 	viper.BindPFlags(rootCmd.Flags()) | ||||||
|   | |||||||
| @@ -1,8 +1,14 @@ | |||||||
|  | import { useAppContext } from "@/context/app-context"; | ||||||
| import { LanguageSelector } from "../language/language"; | import { LanguageSelector } from "../language/language"; | ||||||
|  |  | ||||||
| export const Layout = ({ children }: { children: React.ReactNode }) => { | export const Layout = ({ children }: { children: React.ReactNode }) => { | ||||||
|  |   const { backgroundImage } = useAppContext(); | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|     <div className="flex flex-col justify-center items-center min-h-svh bg-[url(/background.jpg)] bg-cover"> |     <div | ||||||
|  |       className={`flex flex-col justify-center items-center min-h-svh bg-[url(${backgroundImage})] bg-cover`} | ||||||
|  |     > | ||||||
|  |       <img></img> | ||||||
|       <LanguageSelector /> |       <LanguageSelector /> | ||||||
|       {children} |       {children} | ||||||
|     </div> |     </div> | ||||||
|   | |||||||
| @@ -7,7 +7,8 @@ export const appContextSchema = z.object({ | |||||||
|     genericName: z.string(), |     genericName: z.string(), | ||||||
|     domain: z.string(), |     domain: z.string(), | ||||||
|     forgotPasswordMessage: z.string(), |     forgotPasswordMessage: z.string(), | ||||||
|     oauthAutoRedirect: z.string(), |     // oauthAutoRedirect: z.string(), | ||||||
|  |     backgroundImage: z.string(), | ||||||
| }) | }) | ||||||
|  |  | ||||||
| export type AppContextSchema = z.infer<typeof appContextSchema>; | export type AppContextSchema = z.infer<typeof appContextSchema>; | ||||||
| @@ -448,6 +448,7 @@ func (h *Handlers) AppHandler(c *gin.Context) { | |||||||
| 		GenericName:           h.Config.GenericName, | 		GenericName:           h.Config.GenericName, | ||||||
| 		Domain:                h.Config.Domain, | 		Domain:                h.Config.Domain, | ||||||
| 		ForgotPasswordMessage: h.Config.ForgotPasswordMessage, | 		ForgotPasswordMessage: h.Config.ForgotPasswordMessage, | ||||||
|  | 		BackgroundImage:       h.Config.BackgroundImage, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Return app context | 	// Return app context | ||||||
|   | |||||||
| @@ -48,6 +48,7 @@ type AppContext struct { | |||||||
| 	GenericName           string   `json:"genericName"` | 	GenericName           string   `json:"genericName"` | ||||||
| 	Domain                string   `json:"domain"` | 	Domain                string   `json:"domain"` | ||||||
| 	ForgotPasswordMessage string   `json:"forgotPasswordMessage"` | 	ForgotPasswordMessage string   `json:"forgotPasswordMessage"` | ||||||
|  | 	BackgroundImage       string   `json:"backgroundImage"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // Totp request is the request for the totp endpoint | // Totp request is the request for the totp endpoint | ||||||
|   | |||||||
| @@ -33,6 +33,7 @@ type Config struct { | |||||||
| 	LoginTimeout            int    `mapstructure:"login-timeout"` | 	LoginTimeout            int    `mapstructure:"login-timeout"` | ||||||
| 	LoginMaxRetries         int    `mapstructure:"login-max-retries"` | 	LoginMaxRetries         int    `mapstructure:"login-max-retries"` | ||||||
| 	FogotPasswordMessage    string `mapstructure:"forgot-password-message" validate:"required"` | 	FogotPasswordMessage    string `mapstructure:"forgot-password-message" validate:"required"` | ||||||
|  | 	BackgroundImage         string `mapstructure:"background-image" validate:"required"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // Server configuration | // Server configuration | ||||||
| @@ -44,6 +45,7 @@ type HandlersConfig struct { | |||||||
| 	GenericName           string | 	GenericName           string | ||||||
| 	Title                 string | 	Title                 string | ||||||
| 	ForgotPasswordMessage string | 	ForgotPasswordMessage string | ||||||
|  | 	BackgroundImage       string | ||||||
| } | } | ||||||
|  |  | ||||||
| // OAuthConfig is the configuration for the providers | // OAuthConfig is the configuration for the providers | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stavros
					Stavros