From be0e022c9226bb362ae9843a1a5b4296f0329831 Mon Sep 17 00:00:00 2001 From: Daniel Krol Date: Fri, 29 Jul 2022 13:42:25 -0400 Subject: [PATCH] Check/log email configs on startup. --- main.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 339d733..f496691 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "lbryio/lbry-id/auth" "lbryio/lbry-id/env" + "lbryio/lbry-id/mail" "lbryio/lbry-id/server" "lbryio/lbry-id/store" ) @@ -22,8 +23,35 @@ func storeInit() (s store.Store) { return } +// Output information about the email verification mode so the user can confirm +// what they set. Also trigger an error on startup if there's a configuration +// problem. +func logEmailVerificationMode(e *env.Env) (err error) { + verificationMode, err := env.GetAccountVerificationMode(e) + if err != nil { + return + } + accountWhitelist, err := env.GetAccountWhitelist(e, verificationMode) + if err != nil { + return + } + + if verificationMode == env.AccountVerificationModeWhitelist { + log.Printf("Account verification mode: %s - Whitelist has %d email(s).\n", verificationMode, len(accountWhitelist)) + } else { + log.Printf("Account verification mode: %s", verificationMode) + } + return +} + func main() { + e := env.Env{} + + if err := logEmailVerificationMode(&e); err != nil { + log.Fatal(err.Error()) + } + store := storeInit() - srv := server.Init(&auth.Auth{}, &store, &env.Env{}) + srv := server.Init(&auth.Auth{}, &store, &e, &mail.Mail{}) srv.Serve() }