Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix branding update #326

Merged
merged 4 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/auth0_branding_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ auth0 branding update [flags]

```
auth0 branding update
auth0 branding update --accent '#B24592' --background '#F2DDEC'
auth0 branding update -a '#B24592' -b '#F2DDEC --logo 'https://example.com/logo.png
auth0 branding update --accent "#FF4F40" --background "#2A2E35"
auth0 branding update -a "#FF4F40" -b "#2A2E35" --logo "https://example.com/logo.png"
```

### Options
Expand Down
30 changes: 16 additions & 14 deletions internal/cli/branding.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func emailTemplateCmd(cli *cli) *cobra.Command {
return cmd
}


func showBrandingCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "show",
Expand Down Expand Up @@ -157,8 +156,8 @@ func updateBrandingCmd(cli *cli) *cobra.Command {
Short: "Update the custom branding settings for Universal Login",
Long: "Update the custom branding settings for Universal Login.",
Example: `auth0 branding update
auth0 branding update --accent '#B24592' --background '#F2DDEC'
auth0 branding update -a '#B24592' -b '#F2DDEC --logo 'https://example.com/logo.png`,
auth0 branding update --accent "#FF4F40" --background "#2A2E35"
auth0 branding update -a "#FF4F40" -b "#2A2E35" --logo "https://example.com/logo.png"`,
RunE: func(cmd *cobra.Command, args []string) error {
var current *management.Branding

Expand All @@ -182,21 +181,24 @@ auth0 branding update -a '#B24592' -b '#F2DDEC --logo 'https://example.com/logo.

// Load updated values into a fresh branding instance
b := &management.Branding{}
isAccentColorSet := len(inputs.AccentColor) > 0
isBackgroundColorSet := len(inputs.BackgroundColor) > 0
currentHasColors := current.Colors != nil

if b.Colors == nil {
if isAccentColorSet || isBackgroundColorSet || currentHasColors {
b.Colors = &management.BrandingColors{}
}

if len(inputs.AccentColor) == 0 {
b.Colors.Primary = current.GetColors().Primary
} else {
b.Colors.Primary = &inputs.AccentColor
}
if isAccentColorSet {
b.Colors.Primary = &inputs.AccentColor
} else if currentHasColors {
b.Colors.Primary = current.Colors.Primary
}

if len(inputs.BackgroundColor) == 0 {
b.Colors.PageBackground = current.GetColors().PageBackground
} else {
b.Colors.PageBackground = &inputs.BackgroundColor
if isBackgroundColorSet {
b.Colors.PageBackground = &inputs.BackgroundColor
} else if currentHasColors {
b.Colors.PageBackground = current.Colors.PageBackground
}
}

if len(inputs.LogoURL) == 0 {
Expand Down