mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
19621acfd3
Implementation of new notification policy with functionality to send email when a password is changed
85 lines
2.5 KiB
Go
85 lines
2.5 KiB
Go
package domain
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
)
|
|
|
|
const (
|
|
InitCodeMessageType = "InitCode"
|
|
PasswordResetMessageType = "PasswordReset"
|
|
VerifyEmailMessageType = "VerifyEmail"
|
|
VerifyPhoneMessageType = "VerifyPhone"
|
|
DomainClaimedMessageType = "DomainClaimed"
|
|
PasswordlessRegistrationMessageType = "PasswordlessRegistration"
|
|
PasswordChangeMessageType = "PasswordChange"
|
|
MessageTitle = "Title"
|
|
MessagePreHeader = "PreHeader"
|
|
MessageSubject = "Subject"
|
|
MessageGreeting = "Greeting"
|
|
MessageText = "Text"
|
|
MessageButtonText = "ButtonText"
|
|
MessageFooterText = "Footer"
|
|
)
|
|
|
|
type MessageTexts struct {
|
|
InitCode CustomMessageText
|
|
PasswordReset CustomMessageText
|
|
VerifyEmail CustomMessageText
|
|
VerifyPhone CustomMessageText
|
|
DomainClaimed CustomMessageText
|
|
PasswordlessRegistration CustomMessageText
|
|
PasswordChange CustomMessageText
|
|
}
|
|
|
|
type CustomMessageText struct {
|
|
models.ObjectRoot
|
|
|
|
State PolicyState
|
|
Default bool
|
|
MessageTextType string
|
|
Language language.Tag
|
|
Title string
|
|
PreHeader string
|
|
Subject string
|
|
Greeting string
|
|
Text string
|
|
ButtonText string
|
|
FooterText string
|
|
}
|
|
|
|
func (m *CustomMessageText) IsValid() bool {
|
|
return m.MessageTextType != "" && m.Language != language.Und
|
|
}
|
|
|
|
func (m *MessageTexts) GetMessageTextByType(msgType string) *CustomMessageText {
|
|
switch msgType {
|
|
case InitCodeMessageType:
|
|
return &m.InitCode
|
|
case PasswordResetMessageType:
|
|
return &m.PasswordReset
|
|
case VerifyEmailMessageType:
|
|
return &m.VerifyEmail
|
|
case VerifyPhoneMessageType:
|
|
return &m.VerifyPhone
|
|
case DomainClaimedMessageType:
|
|
return &m.DomainClaimed
|
|
case PasswordlessRegistrationMessageType:
|
|
return &m.PasswordlessRegistration
|
|
case PasswordChangeMessageType:
|
|
return &m.PasswordChange
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func IsMessageTextType(textType string) bool {
|
|
return textType == InitCodeMessageType ||
|
|
textType == PasswordResetMessageType ||
|
|
textType == VerifyEmailMessageType ||
|
|
textType == VerifyPhoneMessageType ||
|
|
textType == DomainClaimedMessageType ||
|
|
textType == PasswordlessRegistrationMessageType ||
|
|
textType == PasswordChangeMessageType
|
|
}
|