35 lines
801 B
Go
35 lines
801 B
Go
|
|
package config
|
||
|
|
|
||
|
|
// Config is member module settings (embedded in gateway root config).
|
||
|
|
type 幫Config struct {
|
||
|
|
OTP OTPConfig `json:",optional"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type OTPConfig struct {
|
||
|
|
Length int `json:",optional"`
|
||
|
|
TTLSeconds int `json:",optional"`
|
||
|
|
MaxAttempts int `json:",optional"`
|
||
|
|
ResendCooldownSeconds int `json:",optional"`
|
||
|
|
DailyVerifyLimit int `json:",optional"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// Defaults returns zero-value-safe defaults.
|
||
|
|
func (c Config) Defaults() Config {
|
||
|
|
if c.OTP.Length <= 0 {
|
||
|
|
c.OTP.Length = 6
|
||
|
|
}
|
||
|
|
if c.OTP.TTLSeconds <= 0 {
|
||
|
|
c.OTP.TTLSeconds = 300
|
||
|
|
}
|
||
|
|
if c.OTP.MaxAttempts <= 0 {
|
||
|
|
c.OTP.MaxAttempts = 5
|
||
|
|
}
|
||
|
|
if c.OTP.ResendCooldownSeconds <= 0 {
|
||
|
|
c.OTP.ResendCooldownSeconds = 60
|
||
|
|
}
|
||
|
|
if c.OTP.DailyVerifyLimit <= 0 {
|
||
|
|
c.OTP.DailyVerifyLimit = 10
|
||
|
|
}
|
||
|
|
return c
|
||
|
|
}
|