mirror of https://github.com/hrfee/jfa-go.git
Compare commits
3 Commits
1bfec54c93
...
548dceda28
Author | SHA1 | Date |
---|---|---|
Harvey Tindall | 548dceda28 | |
Harvey Tindall | e67b2e91fb | |
Harvey Tindall | 412fe31da6 |
2
api.go
2
api.go
|
@ -418,7 +418,7 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
||||||
"username": req.Username,
|
"username": req.Username,
|
||||||
"password": req.Password,
|
"password": req.Password,
|
||||||
"telegramPIN": req.TelegramPIN,
|
"telegramPIN": req.TelegramPIN,
|
||||||
"exp": strconv.FormatInt(time.Now().Add(time.Hour*12).Unix(), 10),
|
"exp": time.Now().Add(time.Hour * 12).Unix(),
|
||||||
"type": "confirmation",
|
"type": "confirmation",
|
||||||
}
|
}
|
||||||
tk := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
tk := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||||
|
|
|
@ -246,7 +246,7 @@
|
||||||
"requires_restart": true,
|
"requires_restart": true,
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"value": "",
|
"value": "",
|
||||||
"description": "URL base for when running jfa-go with a reverse proxy in a subfolder."
|
"description": "URL base for when running jfa-go with a reverse proxy in a subfolder. include preceding /, e.g \"/accounts\"."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
17
email.go
17
email.go
|
@ -181,8 +181,7 @@ func (emailer *Emailer) NewMailgun(url, key string) {
|
||||||
func (emailer *Emailer) NewSMTP(server string, port int, username, password string, sslTLS bool, certPath string) (err error) {
|
func (emailer *Emailer) NewSMTP(server string, port int, username, password string, sslTLS bool, certPath string) (err error) {
|
||||||
// x509.SystemCertPool is unavailable on windows
|
// x509.SystemCertPool is unavailable on windows
|
||||||
if PLATFORM == "windows" {
|
if PLATFORM == "windows" {
|
||||||
emailer.sender = &SMTP{
|
sender := &SMTP{
|
||||||
auth: smtp.PlainAuth("", username, password, server),
|
|
||||||
server: server,
|
server: server,
|
||||||
port: port,
|
port: port,
|
||||||
sslTLS: sslTLS,
|
sslTLS: sslTLS,
|
||||||
|
@ -191,6 +190,10 @@ func (emailer *Emailer) NewSMTP(server string, port int, username, password stri
|
||||||
ServerName: server,
|
ServerName: server,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if username != "" || password != "" {
|
||||||
|
sender.auth = smtp.PlainAuth("", username, password, server)
|
||||||
|
}
|
||||||
|
emailer.sender = sender
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rootCAs, err := x509.SystemCertPool()
|
rootCAs, err := x509.SystemCertPool()
|
||||||
|
@ -204,8 +207,7 @@ func (emailer *Emailer) NewSMTP(server string, port int, username, password stri
|
||||||
err = errors.New("Failed to append cert to pool")
|
err = errors.New("Failed to append cert to pool")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emailer.sender = &SMTP{
|
sender := &SMTP{
|
||||||
auth: smtp.PlainAuth("", username, password, server),
|
|
||||||
server: server,
|
server: server,
|
||||||
port: port,
|
port: port,
|
||||||
sslTLS: sslTLS,
|
sslTLS: sslTLS,
|
||||||
|
@ -215,6 +217,10 @@ func (emailer *Emailer) NewSMTP(server string, port int, username, password stri
|
||||||
RootCAs: rootCAs,
|
RootCAs: rootCAs,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if username != "" || password != "" {
|
||||||
|
sender.auth = smtp.PlainAuth("", username, password, server)
|
||||||
|
}
|
||||||
|
emailer.sender = sender
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,6 +312,9 @@ func (emailer *Emailer) confirmationValues(code, username, key string, app *appC
|
||||||
} else {
|
} else {
|
||||||
message := app.config.Section("messages").Key("message").String()
|
message := app.config.Section("messages").Key("message").String()
|
||||||
inviteLink := app.config.Section("invite_emails").Key("url_base").String()
|
inviteLink := app.config.Section("invite_emails").Key("url_base").String()
|
||||||
|
if !strings.HasSuffix(inviteLink, "/invite") {
|
||||||
|
inviteLink += "/invite"
|
||||||
|
}
|
||||||
inviteLink = fmt.Sprintf("%s/%s?key=%s", inviteLink, code, key)
|
inviteLink = fmt.Sprintf("%s/%s?key=%s", inviteLink, code, key)
|
||||||
template["helloUser"] = emailer.lang.Strings.template("helloUser", tmpl{"username": username})
|
template["helloUser"] = emailer.lang.Strings.template("helloUser", tmpl{"username": username})
|
||||||
template["confirmationURL"] = inviteLink
|
template["confirmationURL"] = inviteLink
|
||||||
|
|
|
@ -100,7 +100,7 @@ func migrateEmailStorage(app *appContext) error {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Email address was type %T, not string: \"%+v\"\n", addr, addr)
|
return fmt.Errorf("email address was type %T, not string: \"%+v\"\n", addr, addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config, err := ini.Load(app.configPath)
|
config, err := ini.Load(app.configPath)
|
||||||
|
|
3
views.go
3
views.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -249,7 +248,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
claims, ok := token.Claims.(jwt.MapClaims)
|
claims, ok := token.Claims.(jwt.MapClaims)
|
||||||
expiryUnix, err := strconv.ParseInt(claims["exp"].(string), 10, 64)
|
expiryUnix := int64(claims["exp"].(float64))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail()
|
fail()
|
||||||
app.err.Printf("Failed to parse key expiry: %s", err)
|
app.err.Printf("Failed to parse key expiry: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue