Add option to generate new pin on start
Added "NewPin" to the settings to regenarate and save a new pin to the settings file on server start.
This commit is contained in:
parent
c3f2c20e4e
commit
b41c93d19d
11
settings.go
11
settings.go
|
@ -36,7 +36,8 @@ type Settings struct {
|
||||||
LogLevel common.LogLevel
|
LogLevel common.LogLevel
|
||||||
LogFile string
|
LogFile string
|
||||||
RoomAccess AccessMode
|
RoomAccess AccessMode
|
||||||
RoomAccessPin string // auto generate this,
|
RoomAccessPin string // The current pin
|
||||||
|
NewPin bool // Auto generate a new pin on start. Overwrites RoomAccessPin if set.
|
||||||
|
|
||||||
// Rate limiting stuff, in seconds
|
// Rate limiting stuff, in seconds
|
||||||
RateLimitChat time.Duration
|
RateLimitChat time.Duration
|
||||||
|
@ -132,8 +133,12 @@ func LoadSettings(filename string) (*Settings, error) {
|
||||||
s.RoomAccess = AccessOpen
|
s.RoomAccess = AccessOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.RoomAccess != AccessOpen && len(s.RoomAccessPin) == 0 {
|
if (s.RoomAccess != AccessOpen && len(s.RoomAccessPin) == 0) || s.NewPin {
|
||||||
s.RoomAccessPin = "1234"
|
pin, err := s.generateNewPin()
|
||||||
|
if err != nil {
|
||||||
|
common.LogErrorf("Unable to generate new pin: %v", err)
|
||||||
|
}
|
||||||
|
common.LogInfof("New pin generated: %s", pin)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't use LogInfof() here. Log isn't setup yet when LoadSettings() is called from init().
|
// Don't use LogInfof() here. Log isn't setup yet when LoadSettings() is called from init().
|
||||||
|
|
Loading…
Reference in New Issue