2024-08-17 21:57:14 +02:00
|
|
|
package model
|
|
|
|
|
|
2025-03-23 13:21:44 -07:00
|
|
|
import (
|
|
|
|
|
"strconv"
|
2025-03-27 10:20:39 -07:00
|
|
|
"time"
|
2025-03-23 13:21:44 -07:00
|
|
|
)
|
|
|
|
|
|
2024-08-17 21:57:14 +02:00
|
|
|
type AppConfigVariable struct {
|
2024-10-26 00:15:31 +02:00
|
|
|
Key string `gorm:"primaryKey;not null"`
|
|
|
|
|
Type string
|
|
|
|
|
IsPublic bool
|
|
|
|
|
IsInternal bool
|
|
|
|
|
Value string
|
|
|
|
|
DefaultValue string
|
2024-08-17 21:57:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-03-27 10:20:39 -07:00
|
|
|
// IsTrue returns true if the value is a truthy string, such as "true", "t", "yes", "1", etc.
|
2025-03-23 13:21:44 -07:00
|
|
|
func (a *AppConfigVariable) IsTrue() bool {
|
|
|
|
|
ok, _ := strconv.ParseBool(a.Value)
|
|
|
|
|
return ok
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-27 10:20:39 -07:00
|
|
|
// AsDurationMinutes returns the value as a time.Duration, interpreting the string as a whole number of minutes.
|
|
|
|
|
func (a *AppConfigVariable) AsDurationMinutes() time.Duration {
|
|
|
|
|
val, err := strconv.Atoi(a.Value)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return time.Duration(val) * time.Minute
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-17 21:57:14 +02:00
|
|
|
type AppConfig struct {
|
2025-01-19 06:02:07 -06:00
|
|
|
// General
|
2024-08-17 21:57:14 +02:00
|
|
|
AppName AppConfigVariable
|
2024-10-28 18:45:27 +01:00
|
|
|
SessionDuration AppConfigVariable
|
|
|
|
|
EmailsVerified AppConfigVariable
|
|
|
|
|
AllowOwnAccountEdit AppConfigVariable
|
2025-01-19 06:02:07 -06:00
|
|
|
// Internal
|
2024-08-17 21:57:14 +02:00
|
|
|
BackgroundImageType AppConfigVariable
|
2024-10-03 11:27:31 +02:00
|
|
|
LogoLightImageType AppConfigVariable
|
|
|
|
|
LogoDarkImageType AppConfigVariable
|
2025-01-19 06:02:07 -06:00
|
|
|
// Email
|
2025-01-20 18:50:58 +08:00
|
|
|
SmtpHost AppConfigVariable
|
|
|
|
|
SmtpPort AppConfigVariable
|
|
|
|
|
SmtpFrom AppConfigVariable
|
|
|
|
|
SmtpUser AppConfigVariable
|
|
|
|
|
SmtpPassword AppConfigVariable
|
|
|
|
|
SmtpTls AppConfigVariable
|
|
|
|
|
SmtpSkipCertVerify AppConfigVariable
|
|
|
|
|
EmailLoginNotificationEnabled AppConfigVariable
|
2025-01-19 15:30:31 +01:00
|
|
|
EmailOneTimeAccessEnabled AppConfigVariable
|
2025-01-19 06:02:07 -06:00
|
|
|
// LDAP
|
|
|
|
|
LdapEnabled AppConfigVariable
|
|
|
|
|
LdapUrl AppConfigVariable
|
|
|
|
|
LdapBindDn AppConfigVariable
|
|
|
|
|
LdapBindPassword AppConfigVariable
|
|
|
|
|
LdapBase AppConfigVariable
|
2025-02-08 11:16:57 -06:00
|
|
|
LdapUserSearchFilter AppConfigVariable
|
|
|
|
|
LdapUserGroupSearchFilter AppConfigVariable
|
2025-01-19 06:02:07 -06:00
|
|
|
LdapSkipCertVerify AppConfigVariable
|
|
|
|
|
LdapAttributeUserUniqueIdentifier AppConfigVariable
|
|
|
|
|
LdapAttributeUserUsername AppConfigVariable
|
|
|
|
|
LdapAttributeUserEmail AppConfigVariable
|
|
|
|
|
LdapAttributeUserFirstName AppConfigVariable
|
|
|
|
|
LdapAttributeUserLastName AppConfigVariable
|
2025-02-19 14:28:45 +01:00
|
|
|
LdapAttributeUserProfilePicture AppConfigVariable
|
2025-02-16 11:27:07 -06:00
|
|
|
LdapAttributeGroupMember AppConfigVariable
|
2025-01-19 06:02:07 -06:00
|
|
|
LdapAttributeGroupUniqueIdentifier AppConfigVariable
|
|
|
|
|
LdapAttributeGroupName AppConfigVariable
|
|
|
|
|
LdapAttributeAdminGroup AppConfigVariable
|
2024-08-17 21:57:14 +02:00
|
|
|
}
|