Compare commits
7 Commits
0.8.1.test
...
0.8.2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2137d8ef5d | ||
![]() |
8178fa6b62 | ||
![]() |
303a3cbbbe | ||
![]() |
9173b340c8 | ||
![]() |
df192bed4d | ||
![]() |
8d2371c14e | ||
![]() |
5ed669e0da |
@@ -8,4 +8,4 @@ build
|
|||||||
.env
|
.env
|
||||||
data.db
|
data.db
|
||||||
app/node_modules
|
app/node_modules
|
||||||
app/build
|
app/build
|
||||||
|
@@ -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{}
|
||||||
@@ -26,6 +27,7 @@ var (
|
|||||||
DISABLE_EMAIL_VERIFICATION = false
|
DISABLE_EMAIL_VERIFICATION = false
|
||||||
DISABLE_BASIC_AUTHENTICATION = false
|
DISABLE_BASIC_AUTHENTICATION = false
|
||||||
DISABLE_MAGIC_LINK_LOGIN = false
|
DISABLE_MAGIC_LINK_LOGIN = false
|
||||||
|
DISABLE_LOGIN_PAGE = false
|
||||||
|
|
||||||
// ROLES
|
// ROLES
|
||||||
ROLES = []string{}
|
ROLES = []string{}
|
||||||
|
@@ -27,19 +27,18 @@ 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
|
||||||
|
|
||||||
err := smtp.SendMail(constants.SMTP_HOST+":"+constants.SMTP_PORT,
|
err := smtp.SendMail(constants.SMTP_HOST+":"+constants.SMTP_PORT,
|
||||||
smtp.PlainAuth("", sender.User, sender.Password, constants.SMTP_HOST),
|
smtp.PlainAuth("", sender.User, sender.Password, constants.SMTP_HOST),
|
||||||
sender.User, Dest, []byte(msg))
|
constants.SENDER_EMAIL, Dest, []byte(msg))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
log.Printf("smtp error: %s", err)
|
log.Printf("smtp error: %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
15
server/env/env.go
vendored
15
server/env/env.go
vendored
@@ -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 == "" {
|
||||||
@@ -172,8 +176,9 @@ func InitEnv() {
|
|||||||
constants.DISABLE_BASIC_AUTHENTICATION = os.Getenv("DISABLE_BASIC_AUTHENTICATION") == "true"
|
constants.DISABLE_BASIC_AUTHENTICATION = os.Getenv("DISABLE_BASIC_AUTHENTICATION") == "true"
|
||||||
constants.DISABLE_EMAIL_VERIFICATION = os.Getenv("DISABLE_EMAIL_VERIFICATION") == "true"
|
constants.DISABLE_EMAIL_VERIFICATION = os.Getenv("DISABLE_EMAIL_VERIFICATION") == "true"
|
||||||
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"
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
@@ -32,14 +32,17 @@ func main() {
|
|||||||
|
|
||||||
router := router.InitRouter()
|
router := router.InitRouter()
|
||||||
|
|
||||||
// login wall app related routes.
|
// login page app related routes.
|
||||||
// if we put them in router file then tests would fail as templates or build path will be different
|
// if we put them in router file then tests would fail as templates or build path will be different
|
||||||
router.LoadHTMLGlob("templates/*")
|
if !constants.DISABLE_LOGIN_PAGE {
|
||||||
app := router.Group("/app")
|
router.LoadHTMLGlob("templates/*")
|
||||||
{
|
app := router.Group("/app")
|
||||||
app.Static("/build", "app/build")
|
{
|
||||||
app.GET("/", handlers.AppHandler())
|
app.Static("/build", "app/build")
|
||||||
app.GET("/reset-password", handlers.AppHandler())
|
app.GET("/", handlers.AppHandler())
|
||||||
|
app.GET("/reset-password", handlers.AppHandler())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
router.Run(":" + constants.PORT)
|
router.Run(":" + constants.PORT)
|
||||||
}
|
}
|
||||||
|
@@ -14,4 +14,4 @@
|
|||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/app/build/index.js"></script>
|
<script type="module" src="/app/build/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user