mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
f680dd934d
* chore: rename package errors to zerrors * rename package errors to gerrors * fix error related linting issues * fix zitadel error assertion * fix gosimple linting issues * fix deprecated linting issues * resolve gci linting issues * fix import structure --------- Co-authored-by: Elio Bischof <elio@zitadel.com>
76 lines
2.4 KiB
Go
76 lines
2.4 KiB
Go
package domain
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
const (
|
|
InitCodeMessageType = "InitCode"
|
|
PasswordResetMessageType = "PasswordReset"
|
|
VerifyEmailMessageType = "VerifyEmail"
|
|
VerifyPhoneMessageType = "VerifyPhone"
|
|
VerifySMSOTPMessageType = "VerifySMSOTP"
|
|
VerifyEmailOTPMessageType = "VerifyEmailOTP"
|
|
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(supportedLanguages []language.Tag) error {
|
|
if m.MessageTextType == "" {
|
|
return zerrors.ThrowInvalidArgument(nil, "INSTANCE-kd9fs", "Errors.CustomMessageText.Invalid")
|
|
}
|
|
if err := LanguageIsDefined(m.Language); err != nil {
|
|
return err
|
|
}
|
|
return LanguagesAreSupported(supportedLanguages, m.Language)
|
|
}
|
|
|
|
func IsMessageTextType(textType string) bool {
|
|
return textType == InitCodeMessageType ||
|
|
textType == PasswordResetMessageType ||
|
|
textType == VerifyEmailMessageType ||
|
|
textType == VerifyPhoneMessageType ||
|
|
textType == VerifySMSOTPMessageType ||
|
|
textType == VerifyEmailOTPMessageType ||
|
|
textType == DomainClaimedMessageType ||
|
|
textType == PasswordlessRegistrationMessageType ||
|
|
textType == PasswordChangeMessageType
|
|
}
|