diff --git a/internal/cli/universal_login_templates.go b/internal/cli/universal_login_templates.go index ae0b5842b..d22d5b21f 100644 --- a/internal/cli/universal_login_templates.go +++ b/internal/cli/universal_login_templates.go @@ -275,17 +275,18 @@ func ensureCustomDomainIsEnabled(ctx context.Context, api *auth0.API) error { } func fetchBrandingSettingsOrUseDefaults(ctx context.Context, api *auth0.API) *management.Branding { - brandingSettings, err := api.Branding.Read(management.Context(ctx)) - if err != nil { - brandingSettings = &management.Branding{} // If we error we'll provide defaults. + brandingSettings, _ := api.Branding.Read(management.Context(ctx)) + if brandingSettings == nil { + brandingSettings = &management.Branding{} } - if brandingSettings.GetColors() == nil { + if brandingSettings.Colors == nil { brandingSettings.Colors = &management.BrandingColors{ Primary: auth0.String(defaultPrimaryColor), PageBackground: auth0.String(defaultBackgroundColor), } } + if brandingSettings.LogoURL == nil { brandingSettings.LogoURL = auth0.String(defaultLogoURL) } diff --git a/internal/cli/universal_login_templates_test.go b/internal/cli/universal_login_templates_test.go index 818c4501d..729d7e189 100644 --- a/internal/cli/universal_login_templates_test.go +++ b/internal/cli/universal_login_templates_test.go @@ -116,6 +116,17 @@ func TestFetchBrandingSettingsOrUseDefaults(t *testing.T) { }, { name: "no branding settings", + branding: nil, + assertOutput: func(t testing.TB, branding *management.Branding) { + assert.NotNil(t, branding) + assert.NotNil(t, branding.Colors) + assert.Equal(t, branding.Colors.GetPrimary(), defaultPrimaryColor) + assert.Equal(t, branding.Colors.GetPageBackground(), defaultBackgroundColor) + assert.Equal(t, branding.GetLogoURL(), defaultLogoURL) + }, + }, + { + name: "empty branding settings", branding: &management.Branding{}, assertOutput: func(t testing.TB, branding *management.Branding) { assert.NotNil(t, branding)