mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
fix: add port to SMTP host label (#4980)
* fix: add port to SMTP host label * fix gRPC request message * fix: validate port in backend * make defaults.yaml host field more clear * add placeholder smtp host field * make ipv6 smtp host valid * hide smtp password input * fix smtp host not filled * dont let browsers prefill smtp password
This commit is contained in:
@@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
@@ -98,13 +99,14 @@ func (c *Commands) RemoveSMTPConfig(ctx context.Context) (*domain.ObjectDetails,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Commands) prepareAddSMTPConfig(a *instance.Aggregate, from, name, host, user string, password []byte, tls bool) preparation.Validation {
|
||||
func (c *Commands) prepareAddSMTPConfig(a *instance.Aggregate, from, name, hostAndPort, user string, password []byte, tls bool) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if from = strings.TrimSpace(from); from == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "INST-mruNY", "Errors.Invalid.Argument")
|
||||
}
|
||||
if host = strings.TrimSpace(host); host == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "INST-SF3g1", "Errors.Invalid.Argument")
|
||||
hostAndPort = strings.TrimSpace(hostAndPort)
|
||||
if _, _, err := net.SplitHostPort(hostAndPort); err != nil {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "INST-9JdRe", "Errors.Invalid.Argument")
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
fromSplitted := strings.Split(from, "@")
|
||||
@@ -134,7 +136,7 @@ func (c *Commands) prepareAddSMTPConfig(a *instance.Aggregate, from, name, host,
|
||||
tls,
|
||||
from,
|
||||
name,
|
||||
host,
|
||||
hostAndPort,
|
||||
user,
|
||||
smtpPassword,
|
||||
),
|
||||
@@ -143,15 +145,15 @@ func (c *Commands) prepareAddSMTPConfig(a *instance.Aggregate, from, name, host,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Commands) prepareChangeSMTPConfig(a *instance.Aggregate, from, name, host, user string, tls bool) preparation.Validation {
|
||||
func (c *Commands) prepareChangeSMTPConfig(a *instance.Aggregate, from, name, hostAndPort, user string, tls bool) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if from = strings.TrimSpace(from); from == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "INST-ASv2d", "Errors.Invalid.Argument")
|
||||
}
|
||||
if host = strings.TrimSpace(host); host == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "INST-VDwvq", "Errors.Invalid.Argument")
|
||||
hostAndPort = strings.TrimSpace(hostAndPort)
|
||||
if _, _, err := net.SplitHostPort(hostAndPort); err != nil {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "INST-Kv875", "Errors.Invalid.Argument")
|
||||
}
|
||||
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
fromSplitted := strings.Split(from, "@")
|
||||
senderDomain := fromSplitted[len(fromSplitted)-1]
|
||||
@@ -172,7 +174,7 @@ func (c *Commands) prepareChangeSMTPConfig(a *instance.Aggregate, from, name, ho
|
||||
tls,
|
||||
from,
|
||||
name,
|
||||
host,
|
||||
hostAndPort,
|
||||
user,
|
||||
)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user