Move SMTP credentials to .env file

This commit is contained in:
2024-04-27 15:43:11 +07:00
parent 2e48192a35
commit dfaf8e999f
4 changed files with 13 additions and 2 deletions

5
.env
View File

@ -13,5 +13,10 @@ DB_USERNAME=root
DB_PASSWORD=test123
DB_NAME=filekeeper
SMTP_HOST=mail.fossy.my.id
SMTP_PORT=25
SMTP_USER=test@fossy.my.id
SMTP_PASSWORD=Test123456
SESSION_NAME=Session
SESSION_MAX_AGE=604800

2
.gitignore vendored
View File

@ -4,5 +4,7 @@
/log
/.idea
.env
*_templ.txt
*_templ.go

View File

@ -15,6 +15,7 @@ import (
forgotPasswordView "github.com/fossyy/filekeeper/view/forgotPassword"
"gorm.io/gorm"
"net/http"
"strconv"
"sync"
"time"
)
@ -34,7 +35,8 @@ var UserForgotPassword = make(map[string]string)
func init() {
log = logger.Logger()
ListForgotPassword = make(map[string]*ForgotPassword)
mailServer = email.NewSmtpServer("mail.fossy.my.id", 25, "test@fossy.my.id", "Test123456")
smtpPort, _ := strconv.Atoi(utils.Getenv("SMTP_PORT"))
mailServer = email.NewSmtpServer(utils.Getenv("SMTP_HOST"), smtpPort, utils.Getenv("SMTP_USER"), utils.Getenv("SMTP_PASSWORD"))
ticker := time.NewTicker(time.Minute)
go func() {
for {

View File

@ -16,6 +16,7 @@ import (
"github.com/google/uuid"
"gorm.io/gorm"
"net/http"
"strconv"
"sync"
"time"
)
@ -34,7 +35,8 @@ var VerifyEmail map[string]string
func init() {
log = logger.Logger()
mailServer = email.NewSmtpServer("mail.fossy.my.id", 25, "test@fossy.my.id", "Test123456")
smtpPort, _ := strconv.Atoi(utils.Getenv("SMTP_PORT"))
mailServer = email.NewSmtpServer(utils.Getenv("SMTP_HOST"), smtpPort, utils.Getenv("SMTP_USER"), utils.Getenv("SMTP_PASSWORD"))
VerifyUser = make(map[string]*UnverifiedUser)
VerifyEmail = make(map[string]string)