mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
f4fa3ecef3
* fix: separate tier of custom text (message and login) * fix: add migration * fix: build problems * fix: tests * Update internal/api/grpc/admin/features.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/api/grpc/admin/features.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: rename sql file * fix: change sql files * fix: console * fix: console Co-authored-by: Livio Amstutz <livio.a@gmail.com>
80 lines
2.3 KiB
Go
80 lines
2.3 KiB
Go
package domain
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
)
|
|
|
|
const (
|
|
InitCodeMessageType = "InitCode"
|
|
PasswordResetMessageType = "PasswordReset"
|
|
VerifyEmailMessageType = "VerifyEmail"
|
|
VerifyPhoneMessageType = "VerifyPhone"
|
|
DomainClaimedMessageType = "DomainClaimed"
|
|
PasswordlessRegistrationMessageType = "PasswordlessRegistration"
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func IsMessageTextType(textType string) bool {
|
|
return textType == InitCodeMessageType ||
|
|
textType == PasswordResetMessageType ||
|
|
textType == VerifyEmailMessageType ||
|
|
textType == VerifyPhoneMessageType ||
|
|
textType == DomainClaimedMessageType ||
|
|
textType == PasswordlessRegistrationMessageType
|
|
}
|