feat: disable registration
This commit is contained in:
parent
ab74d46c28
commit
39330ce821
17 changed files with 179 additions and 132 deletions
|
|
@ -23,6 +23,8 @@ type Config struct {
|
|||
JWTExpiry time.Duration
|
||||
TokenMagicLinkExpiry time.Duration
|
||||
|
||||
DisableRegistration bool
|
||||
|
||||
MailerSMTPHost string
|
||||
MailerSMTPPort int
|
||||
MailerIMAPHost string
|
||||
|
|
@ -58,6 +60,8 @@ func Load(version string) *Config {
|
|||
JWTExpiry: envDuration("JWT_EXPIRY", 168*time.Hour), // 7 days default
|
||||
TokenMagicLinkExpiry: envDuration("TOKEN_MAGIC_LINK_EXPIRY", 10*time.Minute),
|
||||
|
||||
DisableRegistration: envBool("DISABLE_REGISTRATION", false),
|
||||
|
||||
MailerSMTPHost: envString("MAILER_SMTP_HOST", ""),
|
||||
MailerSMTPPort: envInt("MAILER_SMTP_PORT", 587),
|
||||
MailerIMAPHost: envString("MAILER_IMAP_HOST", ""),
|
||||
|
|
@ -120,6 +124,19 @@ func envInt(key string, def int) int {
|
|||
return int(i)
|
||||
}
|
||||
|
||||
func envBool(key string, def bool) bool {
|
||||
value, ok := os.LookupEnv(key)
|
||||
if !ok || value == "" {
|
||||
return def
|
||||
}
|
||||
b, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
slog.Warn("config invalid bool, using default", "key", key, "value", value, "default", def)
|
||||
return def
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func envDuration(key string, def time.Duration) time.Duration {
|
||||
value, ok := os.LookupEnv(key)
|
||||
if !ok || value == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue