From ddaec544da9170ec468b901161f5b63eb79cdfdc Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Tue, 30 Apr 2024 23:53:15 +0800 Subject: [PATCH] fix: format test otps (#1567) ## What kind of change does this PR introduce? * Apply basic formatting on test OTPs when config is loaded * Fixes #1566 ## What is the current behavior? Please link any relevant issues here. ## What is the new behavior? Feel free to include screenshots if it includes visual changes. ## Additional context Add any other context or screenshots. --- internal/conf/configuration.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/conf/configuration.go b/internal/conf/configuration.go index ac62c77e5..2c8212abd 100644 --- a/internal/conf/configuration.go +++ b/internal/conf/configuration.go @@ -692,6 +692,15 @@ func (config *GlobalConfiguration) ApplyDefaults() error { config.Sms.OtpLength = 6 } + if config.Sms.TestOTP != nil { + formatTestOtps := make(map[string]string) + for phone, otp := range config.Sms.TestOTP { + phone = strings.ReplaceAll(strings.TrimPrefix(phone, "+"), " ", "") + formatTestOtps[phone] = otp + } + config.Sms.TestOTP = formatTestOtps + } + if len(config.Sms.Template) == 0 { config.Sms.Template = "" }