mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
feat: add Help/Support e-mail for instance/org (#5445)
feat: help and support email in privacy policy
This commit is contained in:
@@ -1181,4 +1181,7 @@ func footerKeyToDomain(text *CustomText, result *domain.CustomLoginText) {
|
||||
if text.Key == domain.LoginKeyFooterHelp {
|
||||
result.Footer.Help = text.Text
|
||||
}
|
||||
if text.Key == domain.LoginKeyFooterSupportEmail {
|
||||
result.Footer.SupportEmail = text.Text
|
||||
}
|
||||
}
|
||||
|
@@ -24,9 +24,10 @@ type PrivacyPolicy struct {
|
||||
ResourceOwner string
|
||||
State domain.PolicyState
|
||||
|
||||
TOSLink string
|
||||
PrivacyLink string
|
||||
HelpLink string
|
||||
TOSLink string
|
||||
PrivacyLink string
|
||||
HelpLink string
|
||||
SupportEmail domain.EmailAddress
|
||||
|
||||
IsDefault bool
|
||||
}
|
||||
@@ -72,6 +73,10 @@ var (
|
||||
name: projection.PrivacyPolicyHelpLinkCol,
|
||||
table: privacyTable,
|
||||
}
|
||||
PrivacyColSupportEmail = Column{
|
||||
name: projection.PrivacyPolicySupportEmailCol,
|
||||
table: privacyTable,
|
||||
}
|
||||
PrivacyColIsDefault = Column{
|
||||
name: projection.PrivacyPolicyIsDefaultCol,
|
||||
table: privacyTable,
|
||||
@@ -148,6 +153,7 @@ func preparePrivacyPolicyQuery(ctx context.Context, db prepareDatabase) (sq.Sele
|
||||
PrivacyColPrivacyLink.identifier(),
|
||||
PrivacyColTOSLink.identifier(),
|
||||
PrivacyColHelpLink.identifier(),
|
||||
PrivacyColSupportEmail.identifier(),
|
||||
PrivacyColIsDefault.identifier(),
|
||||
PrivacyColState.identifier(),
|
||||
).
|
||||
@@ -164,6 +170,7 @@ func preparePrivacyPolicyQuery(ctx context.Context, db prepareDatabase) (sq.Sele
|
||||
&policy.PrivacyLink,
|
||||
&policy.TOSLink,
|
||||
&policy.HelpLink,
|
||||
&policy.SupportEmail,
|
||||
&policy.IsDefault,
|
||||
&policy.State,
|
||||
)
|
||||
@@ -179,9 +186,10 @@ func preparePrivacyPolicyQuery(ctx context.Context, db prepareDatabase) (sq.Sele
|
||||
|
||||
func (p *PrivacyPolicy) ToDomain() *domain.PrivacyPolicy {
|
||||
return &domain.PrivacyPolicy{
|
||||
TOSLink: p.TOSLink,
|
||||
PrivacyLink: p.PrivacyLink,
|
||||
HelpLink: p.HelpLink,
|
||||
Default: p.IsDefault,
|
||||
TOSLink: p.TOSLink,
|
||||
PrivacyLink: p.PrivacyLink,
|
||||
HelpLink: p.HelpLink,
|
||||
SupportEmail: p.SupportEmail,
|
||||
Default: p.IsDefault,
|
||||
}
|
||||
}
|
||||
|
@@ -13,17 +13,18 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
preparePrivacyPolicyStmt = `SELECT projections.privacy_policies2.id,` +
|
||||
` projections.privacy_policies2.sequence,` +
|
||||
` projections.privacy_policies2.creation_date,` +
|
||||
` projections.privacy_policies2.change_date,` +
|
||||
` projections.privacy_policies2.resource_owner,` +
|
||||
` projections.privacy_policies2.privacy_link,` +
|
||||
` projections.privacy_policies2.tos_link,` +
|
||||
` projections.privacy_policies2.help_link,` +
|
||||
` projections.privacy_policies2.is_default,` +
|
||||
` projections.privacy_policies2.state` +
|
||||
` FROM projections.privacy_policies2` +
|
||||
preparePrivacyPolicyStmt = `SELECT projections.privacy_policies3.id,` +
|
||||
` projections.privacy_policies3.sequence,` +
|
||||
` projections.privacy_policies3.creation_date,` +
|
||||
` projections.privacy_policies3.change_date,` +
|
||||
` projections.privacy_policies3.resource_owner,` +
|
||||
` projections.privacy_policies3.privacy_link,` +
|
||||
` projections.privacy_policies3.tos_link,` +
|
||||
` projections.privacy_policies3.help_link,` +
|
||||
` projections.privacy_policies3.support_email,` +
|
||||
` projections.privacy_policies3.is_default,` +
|
||||
` projections.privacy_policies3.state` +
|
||||
` FROM projections.privacy_policies3` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
preparePrivacyPolicyCols = []string{
|
||||
"id",
|
||||
@@ -34,6 +35,7 @@ var (
|
||||
"privacy_link",
|
||||
"tos_link",
|
||||
"help_link",
|
||||
"support_email",
|
||||
"is_default",
|
||||
"state",
|
||||
}
|
||||
@@ -84,6 +86,7 @@ func Test_PrivacyPolicyPrepares(t *testing.T) {
|
||||
"privacy.ch",
|
||||
"tos.ch",
|
||||
"help.ch",
|
||||
"support@example.com",
|
||||
true,
|
||||
domain.PolicyStateActive,
|
||||
},
|
||||
@@ -99,6 +102,7 @@ func Test_PrivacyPolicyPrepares(t *testing.T) {
|
||||
PrivacyLink: "privacy.ch",
|
||||
TOSLink: "tos.ch",
|
||||
HelpLink: "help.ch",
|
||||
SupportEmail: "support@example.com",
|
||||
IsDefault: true,
|
||||
},
|
||||
},
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
PrivacyPolicyTable = "projections.privacy_policies2"
|
||||
PrivacyPolicyTable = "projections.privacy_policies3"
|
||||
|
||||
PrivacyPolicyIDCol = "id"
|
||||
PrivacyPolicyCreationDateCol = "creation_date"
|
||||
@@ -27,6 +27,7 @@ const (
|
||||
PrivacyPolicyPrivacyLinkCol = "privacy_link"
|
||||
PrivacyPolicyTOSLinkCol = "tos_link"
|
||||
PrivacyPolicyHelpLinkCol = "help_link"
|
||||
PrivacyPolicySupportEmailCol = "support_email"
|
||||
PrivacyPolicyOwnerRemovedCol = "owner_removed"
|
||||
)
|
||||
|
||||
@@ -51,6 +52,7 @@ func newPrivacyPolicyProjection(ctx context.Context, config crdb.StatementHandle
|
||||
crdb.NewColumn(PrivacyPolicyPrivacyLinkCol, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(PrivacyPolicyTOSLinkCol, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(PrivacyPolicyHelpLinkCol, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(PrivacyPolicySupportEmailCol, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(PrivacyPolicyOwnerRemovedCol, crdb.ColumnTypeBool, crdb.Default(false)),
|
||||
},
|
||||
crdb.NewPrimaryKey(PrivacyPolicyInstanceIDCol, PrivacyPolicyIDCol),
|
||||
@@ -128,6 +130,7 @@ func (p *privacyPolicyProjection) reduceAdded(event eventstore.Event) (*handler.
|
||||
handler.NewCol(PrivacyPolicyPrivacyLinkCol, policyEvent.PrivacyLink),
|
||||
handler.NewCol(PrivacyPolicyTOSLinkCol, policyEvent.TOSLink),
|
||||
handler.NewCol(PrivacyPolicyHelpLinkCol, policyEvent.HelpLink),
|
||||
handler.NewCol(PrivacyPolicySupportEmailCol, policyEvent.SupportEmail),
|
||||
handler.NewCol(PrivacyPolicyIsDefaultCol, isDefault),
|
||||
handler.NewCol(PrivacyPolicyResourceOwnerCol, policyEvent.Aggregate().ResourceOwner),
|
||||
handler.NewCol(PrivacyPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
@@ -157,6 +160,9 @@ func (p *privacyPolicyProjection) reduceChanged(event eventstore.Event) (*handle
|
||||
if policyEvent.HelpLink != nil {
|
||||
cols = append(cols, handler.NewCol(PrivacyPolicyHelpLinkCol, *policyEvent.HelpLink))
|
||||
}
|
||||
if policyEvent.SupportEmail != nil {
|
||||
cols = append(cols, handler.NewCol(PrivacyPolicySupportEmailCol, *policyEvent.SupportEmail))
|
||||
}
|
||||
return crdb.NewUpdateStatement(
|
||||
&policyEvent,
|
||||
cols,
|
||||
|
@@ -31,8 +31,8 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
[]byte(`{
|
||||
"tosLink": "http://tos.link",
|
||||
"privacyLink": "http://privacy.link",
|
||||
"helpLink": "http://help.link"
|
||||
}`),
|
||||
"helpLink": "http://help.link",
|
||||
"supportEmail": "support@example.com"}`),
|
||||
), org.PrivacyPolicyAddedEventMapper),
|
||||
},
|
||||
reduce: (&privacyPolicyProjection{}).reduceAdded,
|
||||
@@ -43,7 +43,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.privacy_policies2 (creation_date, change_date, sequence, id, state, privacy_link, tos_link, help_link, is_default, resource_owner, instance_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.privacy_policies3 (creation_date, change_date, sequence, id, state, privacy_link, tos_link, help_link, support_email, is_default, resource_owner, instance_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
@@ -53,6 +53,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
"http://privacy.link",
|
||||
"http://tos.link",
|
||||
"http://help.link",
|
||||
domain.EmailAddress("support@example.com"),
|
||||
false,
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
@@ -72,8 +73,8 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
[]byte(`{
|
||||
"tosLink": "http://tos.link",
|
||||
"privacyLink": "http://privacy.link",
|
||||
"helpLink": "http://help.link"
|
||||
}`),
|
||||
"helpLink": "http://help.link",
|
||||
"supportEmail": "support@example.com"}`),
|
||||
), org.PrivacyPolicyChangedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
@@ -83,13 +84,14 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.privacy_policies2 SET (change_date, sequence, privacy_link, tos_link, help_link) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedStmt: "UPDATE projections.privacy_policies3 SET (change_date, sequence, privacy_link, tos_link, help_link, support_email) = ($1, $2, $3, $4, $5, $6) WHERE (id = $7) AND (instance_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"http://privacy.link",
|
||||
"http://tos.link",
|
||||
"http://help.link",
|
||||
domain.EmailAddress("support@example.com"),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
@@ -115,7 +117,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.privacy_policies2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.privacy_policies3 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -141,7 +143,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.privacy_policies2 WHERE (instance_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.privacy_policies3 WHERE (instance_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -160,8 +162,8 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
[]byte(`{
|
||||
"tosLink": "http://tos.link",
|
||||
"privacyLink": "http://privacy.link",
|
||||
"helpLink": "http://help.link"
|
||||
}`),
|
||||
"helpLink": "http://help.link",
|
||||
"supportEmail": "support@example.com"}`),
|
||||
), instance.PrivacyPolicyAddedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
@@ -171,7 +173,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.privacy_policies2 (creation_date, change_date, sequence, id, state, privacy_link, tos_link, help_link, is_default, resource_owner, instance_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.privacy_policies3 (creation_date, change_date, sequence, id, state, privacy_link, tos_link, help_link, support_email, is_default, resource_owner, instance_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
@@ -181,6 +183,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
"http://privacy.link",
|
||||
"http://tos.link",
|
||||
"http://help.link",
|
||||
domain.EmailAddress("support@example.com"),
|
||||
true,
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
@@ -200,8 +203,8 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
[]byte(`{
|
||||
"tosLink": "http://tos.link",
|
||||
"privacyLink": "http://privacy.link",
|
||||
"helpLink": "http://help.link"
|
||||
}`),
|
||||
"helpLink": "http://help.link",
|
||||
"supportEmail": "support@example.com"}`),
|
||||
), instance.PrivacyPolicyChangedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
@@ -211,13 +214,14 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.privacy_policies2 SET (change_date, sequence, privacy_link, tos_link, help_link) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedStmt: "UPDATE projections.privacy_policies3 SET (change_date, sequence, privacy_link, tos_link, help_link, support_email) = ($1, $2, $3, $4, $5, $6) WHERE (id = $7) AND (instance_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"http://privacy.link",
|
||||
"http://tos.link",
|
||||
"http://help.link",
|
||||
domain.EmailAddress("support@example.com"),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
@@ -243,7 +247,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.privacy_policies2 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
|
||||
expectedStmt: "UPDATE projections.privacy_policies3 SET (change_date, sequence, owner_removed) = ($1, $2, $3) WHERE (instance_id = $4) AND (resource_owner = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
|
Reference in New Issue
Block a user