diff --git a/internal/command/instance.go b/internal/command/instance.go index 415fae3a2a..0bfd1591a0 100644 --- a/internal/command/instance.go +++ b/internal/command/instance.go @@ -501,6 +501,9 @@ func (c *Commands) ChangeSystemConfig(ctx context.Context, externalDomain string if err != nil { return err } + if len(cmds) == 0 { + continue + } _, err = c.eventstore.Push(ctx, cmds...) if err != nil { return err diff --git a/internal/command/instance_domain.go b/internal/command/instance_domain.go index 54e4121bc8..cbf505bc76 100644 --- a/internal/command/instance_domain.go +++ b/internal/command/instance_domain.go @@ -107,6 +107,9 @@ func (c *Commands) addInstanceDomain(a *instance.Aggregate, instanceDomain strin if err != nil { return nil, err } + if consoleChangeEvent == nil { + return events, nil + } return append(events, consoleChangeEvent), nil }, nil } @@ -122,6 +125,9 @@ func (c *Commands) prepareUpdateConsoleRedirectURIs(instanceDomain string) prepa if err != nil { return nil, err } + if consoleChangeEvent == nil { + return nil, nil + } return []eventstore.Command{ consoleChangeEvent, }, nil @@ -146,6 +152,9 @@ func (c *Commands) updateConsoleRedirectURIs(ctx context.Context, filter prepara if !containsURI(appWriteModel.PostLogoutRedirectUris, postLogoutRedirectURI) { changes = append(changes, project.ChangePostLogoutRedirectURIs(append(appWriteModel.PostLogoutRedirectUris, postLogoutRedirectURI))) } + if len(changes) == 0 { + return nil, nil + } return project.NewOIDCConfigChangedEvent( ctx, ProjectAggregateFromWriteModel(&appWriteModel.WriteModel), @@ -154,17 +163,6 @@ func (c *Commands) updateConsoleRedirectURIs(ctx context.Context, filter prepara ) } -// checkUpdateConsoleRedirectURIs validates if the required console uri is present in the redirect_uris and post_logout_redirect_uris -// it will return true only if present in both list, otherwise false -func (c *Commands) checkUpdateConsoleRedirectURIs(instanceDomain string, redirectURIs, postLogoutRedirectURIs []string) bool { - redirectURI := http.BuildHTTP(instanceDomain, c.externalPort, c.externalSecure) + consoleRedirectPath - if !containsURI(redirectURIs, redirectURI) { - return false - } - postLogoutRedirectURI := http.BuildHTTP(instanceDomain, c.externalPort, c.externalSecure) + consolePostLogoutPath - return containsURI(postLogoutRedirectURIs, postLogoutRedirectURI) -} - func setPrimaryInstanceDomain(a *instance.Aggregate, instanceDomain string) preparation.Validation { return func() (preparation.CreateCommands, error) { if instanceDomain = strings.TrimSpace(instanceDomain); instanceDomain == "" { diff --git a/internal/command/system_model.go b/internal/command/system_model.go index 40847cfab7..6637013d55 100644 --- a/internal/command/system_model.go +++ b/internal/command/system_model.go @@ -181,8 +181,5 @@ func (wm *SystemConfigWriteModel) changeConfig(validation *SystemConfigChangesVa } func (wm *SystemConfigWriteModel) changeURIs(validation *SystemConfigChangesValidation, inst *systemConfigChangesInstanceModel, commands *Commands, domain string) { - if commands.checkUpdateConsoleRedirectURIs(domain, inst.RedirectUris, inst.PostLogoutRedirectUris) { - return - } validation.Validations = append(validation.Validations, commands.prepareUpdateConsoleRedirectURIs(domain)) }