Skip to content

Commit

Permalink
Fix branding update (#326)
Browse files Browse the repository at this point in the history
* Fix branding update

* Update docs
  • Loading branch information
Widcket authored Jul 8, 2021
1 parent daf7e30 commit 53f029c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
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

0 comments on commit 53f029c

Please sign in to comment.