From 55ba4996eb69efabeb2f11c7ccdfdb2e6bb67430 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Sun, 17 Jul 2022 13:46:44 -0400 Subject: [PATCH] bot: add override password for staging/testing modes --- bot/bot.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot/bot.go b/bot/bot.go index 66e02fa..2648565 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -318,6 +318,9 @@ func (b *bot) Register(p Plugin, kind Kind, cb Callback) { // GetPassword returns a random password generated for the bot // Passwords expire in 24h and are used for the web interface func (b *bot) GetPassword() string { + if override := b.config.Get("bot.password", ""); override != "" { + return override + } if b.passwordCreated.Before(time.Now().Add(-24 * time.Hour)) { adjs := b.config.GetArray("bot.passwordAdjectives", []string{"very"}) nouns := b.config.GetArray("bot.passwordNouns", []string{"noun"}) @@ -404,10 +407,11 @@ func PluginName(p Plugin) string { } func (b *bot) CheckPassword(secret, password string) bool { + log.Debug().Msgf("CheckPassword(%s, %s) => b.password=%s, b.GetPassword()=%s", secret, password, b.password, b.GetPassword()) if password == "" { return false } - if b.password == password { + if b.GetPassword() == password { return true } parts := strings.SplitN(password, ":", 2)