mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-12 21:30:10 +00:00
Compare commits
3 Commits
1bfec54c93
...
548dceda28
Author | SHA1 | Date | |
---|---|---|---|
548dceda28 | |||
e67b2e91fb | |||
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,
|
||||
"password": req.Password,
|
||||
"telegramPIN": req.TelegramPIN,
|
||||
"exp": strconv.FormatInt(time.Now().Add(time.Hour*12).Unix(), 10),
|
||||
"exp": time.Now().Add(time.Hour * 12).Unix(),
|
||||
"type": "confirmation",
|
||||
}
|
||||
tk := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
|
@ -246,7 +246,7 @@
|
||||
"requires_restart": true,
|
||||
"type": "text",
|
||||
"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) {
|
||||
// x509.SystemCertPool is unavailable on windows
|
||||
if PLATFORM == "windows" {
|
||||
emailer.sender = &SMTP{
|
||||
auth: smtp.PlainAuth("", username, password, server),
|
||||
sender := &SMTP{
|
||||
server: server,
|
||||
port: port,
|
||||
sslTLS: sslTLS,
|
||||
@ -191,6 +190,10 @@ func (emailer *Emailer) NewSMTP(server string, port int, username, password stri
|
||||
ServerName: server,
|
||||
},
|
||||
}
|
||||
if username != "" || password != "" {
|
||||
sender.auth = smtp.PlainAuth("", username, password, server)
|
||||
}
|
||||
emailer.sender = sender
|
||||
return
|
||||
}
|
||||
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")
|
||||
}
|
||||
}
|
||||
emailer.sender = &SMTP{
|
||||
auth: smtp.PlainAuth("", username, password, server),
|
||||
sender := &SMTP{
|
||||
server: server,
|
||||
port: port,
|
||||
sslTLS: sslTLS,
|
||||
@ -215,6 +217,10 @@ func (emailer *Emailer) NewSMTP(server string, port int, username, password stri
|
||||
RootCAs: rootCAs,
|
||||
},
|
||||
}
|
||||
if username != "" || password != "" {
|
||||
sender.auth = smtp.PlainAuth("", username, password, server)
|
||||
}
|
||||
emailer.sender = sender
|
||||
return
|
||||
}
|
||||
|
||||
@ -306,6 +312,9 @@ func (emailer *Emailer) confirmationValues(code, username, key string, app *appC
|
||||
} else {
|
||||
message := app.config.Section("messages").Key("message").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)
|
||||
template["helloUser"] = emailer.lang.Strings.template("helloUser", tmpl{"username": username})
|
||||
template["confirmationURL"] = inviteLink
|
||||
|
@ -100,7 +100,7 @@ func migrateEmailStorage(app *appContext) error {
|
||||
case map[string]interface{}:
|
||||
return nil
|
||||
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)
|
||||
|
3
views.go
3
views.go
@ -4,7 +4,6 @@ import (
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -249,7 +248,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||
return
|
||||
}
|
||||
claims, ok := token.Claims.(jwt.MapClaims)
|
||||
expiryUnix, err := strconv.ParseInt(claims["exp"].(string), 10, 64)
|
||||
expiryUnix := int64(claims["exp"].(float64))
|
||||
if err != nil {
|
||||
fail()
|
||||
app.err.Printf("Failed to parse key expiry: %s", err)
|
||||
|
Loading…
Reference in New Issue
Block a user