Merge pull request #95 from authorizerdev/smtp-improvements

Improve smtp variable names
This commit is contained in:
Lakhan Samani 2022-01-07 19:32:20 +05:30 committed by GitHub
commit 303a3cbbbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View File

@ -11,8 +11,9 @@ var (
DATABASE_NAME = "" DATABASE_NAME = ""
SMTP_HOST = "" SMTP_HOST = ""
SMTP_PORT = "" SMTP_PORT = ""
SMTP_USERNAME = ""
SMTP_PASSWORD = ""
SENDER_EMAIL = "" SENDER_EMAIL = ""
SENDER_PASSWORD = ""
JWT_TYPE = "" JWT_TYPE = ""
JWT_SECRET = "" JWT_SECRET = ""
ALLOWED_ORIGINS = []string{} ALLOWED_ORIGINS = []string{}

View File

@ -27,11 +27,11 @@ type Sender struct {
} }
func NewSender() Sender { func NewSender() Sender {
return Sender{User: constants.SENDER_EMAIL, Password: constants.SENDER_PASSWORD} return Sender{User: constants.SMTP_USERNAME, Password: constants.SMTP_PASSWORD}
} }
func (sender Sender) SendMail(Dest []string, Subject, bodyMessage string) error { func (sender Sender) SendMail(Dest []string, Subject, bodyMessage string) error {
msg := "From: " + sender.User + "\n" + msg := "From: " + constants.SENDER_EMAIL + "\n" +
"To: " + strings.Join(Dest, ",") + "\n" + "To: " + strings.Join(Dest, ",") + "\n" +
"Subject: " + Subject + "\n" + bodyMessage "Subject: " + Subject + "\n" + bodyMessage

14
server/env/env.go vendored
View File

@ -94,12 +94,16 @@ func InitEnv() {
constants.SMTP_PORT = os.Getenv("SMTP_PORT") constants.SMTP_PORT = os.Getenv("SMTP_PORT")
} }
if constants.SENDER_EMAIL == "" { if constants.SMTP_USERNAME == "" {
constants.SENDER_EMAIL = os.Getenv("SENDER_EMAIL") constants.SMTP_USERNAME = os.Getenv("SMTP_USERNAME")
} }
if constants.SENDER_PASSWORD == "" { if constants.SMTP_PASSWORD == "" {
constants.SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD") constants.SMTP_PASSWORD = os.Getenv("SMTP_PASSWORD")
}
if constants.SENDER_EMAIL == "" {
constants.SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
} }
if constants.JWT_SECRET == "" { if constants.JWT_SECRET == "" {
@ -174,7 +178,7 @@ func InitEnv() {
constants.DISABLE_MAGIC_LINK_LOGIN = os.Getenv("DISABLE_MAGIC_LINK_LOGIN") == "true" constants.DISABLE_MAGIC_LINK_LOGIN = os.Getenv("DISABLE_MAGIC_LINK_LOGIN") == "true"
constants.DISABLE_LOGIN_PAGE = os.Getenv("DISABLE_LOGIN_PAGE") == "true" constants.DISABLE_LOGIN_PAGE = os.Getenv("DISABLE_LOGIN_PAGE") == "true"
if constants.SMTP_HOST == "" || constants.SENDER_EMAIL == "" || constants.SENDER_PASSWORD == "" { if constants.SMTP_HOST == "" || constants.SMTP_USERNAME == "" || constants.SMTP_PASSWORD == "" || constants.SENDER_EMAIL == "" {
constants.DISABLE_EMAIL_VERIFICATION = true constants.DISABLE_EMAIL_VERIFICATION = true
constants.DISABLE_MAGIC_LINK_LOGIN = true constants.DISABLE_MAGIC_LINK_LOGIN = true
} }