2022-07-18 00:56:09 +00:00
|
|
|
package templates
|
|
|
|
|
|
|
|
import (
|
2022-12-23 05:06:49 +00:00
|
|
|
th "html/template"
|
|
|
|
"io"
|
|
|
|
tt "text/template"
|
2022-07-18 00:56:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Templates is the struct which holds all the *template.Template values.
|
|
|
|
type Templates struct {
|
|
|
|
notification NotificationTemplates
|
2023-01-03 03:49:02 +00:00
|
|
|
asset AssetTemplates
|
2023-01-07 20:04:06 +00:00
|
|
|
oidc OpenIDConnectTemplates
|
2023-01-03 03:49:02 +00:00
|
|
|
}
|
|
|
|
|
2023-01-07 20:04:06 +00:00
|
|
|
type OpenIDConnectTemplates struct {
|
|
|
|
formpost *th.Template
|
|
|
|
}
|
|
|
|
|
|
|
|
// AssetTemplates are templates for specific key assets.
|
2023-01-03 03:49:02 +00:00
|
|
|
type AssetTemplates struct {
|
|
|
|
index *tt.Template
|
2023-01-07 20:04:06 +00:00
|
|
|
api OpenAPIAssetTemplates
|
2023-01-03 03:49:02 +00:00
|
|
|
}
|
|
|
|
|
2023-01-07 20:04:06 +00:00
|
|
|
// OpenAPIAssetTemplates are asset templates for the OpenAPI specification.
|
|
|
|
type OpenAPIAssetTemplates struct {
|
2023-01-03 03:49:02 +00:00
|
|
|
index *tt.Template
|
|
|
|
spec *tt.Template
|
2022-07-18 00:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NotificationTemplates are the templates for the notification system.
|
|
|
|
type NotificationTemplates struct {
|
2023-04-23 10:59:15 +00:00
|
|
|
reset *EmailTemplate
|
|
|
|
event *EmailTemplate
|
|
|
|
otp *EmailTemplate
|
2022-07-18 00:56:09 +00:00
|
|
|
}
|
|
|
|
|
2022-12-23 05:06:49 +00:00
|
|
|
// Template covers shared implementations between the text and html template.Template.
|
|
|
|
type Template interface {
|
|
|
|
Execute(wr io.Writer, data any) error
|
|
|
|
ExecuteTemplate(wr io.Writer, name string, data any) error
|
|
|
|
Name() string
|
|
|
|
DefinedTemplates() string
|
|
|
|
}
|
2022-07-18 00:56:09 +00:00
|
|
|
|
|
|
|
// Config for the Provider.
|
|
|
|
type Config struct {
|
|
|
|
EmailTemplatesPath string
|
|
|
|
}
|
|
|
|
|
2022-12-23 05:06:49 +00:00
|
|
|
// EmailTemplate is the template type which contains both the html and txt versions of a template.
|
|
|
|
type EmailTemplate struct {
|
|
|
|
HTML *th.Template
|
|
|
|
Text *tt.Template
|
|
|
|
}
|
|
|
|
|
2022-12-27 08:59:08 +00:00
|
|
|
// EmailEventValues are the values used for event templates.
|
|
|
|
type EmailEventValues struct {
|
|
|
|
Title string
|
|
|
|
DisplayName string
|
|
|
|
Details map[string]any
|
|
|
|
RemoteIP string
|
|
|
|
}
|
|
|
|
|
2023-04-23 10:59:15 +00:00
|
|
|
// EmailOneTimePasswordValues are the values used for the one time password template.
|
|
|
|
type EmailOneTimePasswordValues struct {
|
|
|
|
Title string
|
|
|
|
DisplayName string
|
|
|
|
RemoteIP string
|
|
|
|
Identifier string
|
|
|
|
OneTimePassword string
|
2022-07-18 00:56:09 +00:00
|
|
|
}
|
|
|
|
|
2023-04-23 10:59:15 +00:00
|
|
|
// EmailPasswordResetValues are the values used for the password reset template.
|
|
|
|
type EmailPasswordResetValues struct {
|
2022-07-18 00:56:09 +00:00
|
|
|
DisplayName string
|
|
|
|
RemoteIP string
|
|
|
|
LinkURL string
|
|
|
|
LinkText string
|
|
|
|
}
|