mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
settings: add redundant URL base for pwr
having it under "Invite Emails" when they weren't in use was confusing. If only one is set in the config file, it'll be used for both.
This commit is contained in:
parent
6e88c1f4fc
commit
9693ce3dcd
9
api.go
9
api.go
@ -1722,6 +1722,15 @@ func (app *appContext) GetConfig(gc *gin.Context) {
|
|||||||
resp.Sections["discord"].Settings["language"] = tl
|
resp.Sections["discord"].Settings["language"] = tl
|
||||||
resp.Sections["matrix"].Settings["language"] = tl
|
resp.Sections["matrix"].Settings["language"] = tl
|
||||||
|
|
||||||
|
// if setting := resp.Sections["invite_emails"].Settings["url_base"]; setting.Value == "" {
|
||||||
|
// setting.Value = strings.TrimSuffix(resp.Sections["password_resets"].Settings["url_base"].Value.(string), "/invite")
|
||||||
|
// resp.Sections["invite_emails"].Settings["url_base"] = setting
|
||||||
|
// }
|
||||||
|
// if setting := resp.Sections["password_resets"].Settings["url_base"]; setting.Value == "" {
|
||||||
|
// setting.Value = strings.TrimSuffix(resp.Sections["invite_emails"].Settings["url_base"].Value.(string), "/invite")
|
||||||
|
// resp.Sections["password_resets"].Settings["url_base"] = setting
|
||||||
|
// }
|
||||||
|
|
||||||
gc.JSON(200, resp)
|
gc.JSON(200, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,13 @@ func (app *appContext) loadConfig() error {
|
|||||||
app.config.Section("jellyfin").Key("version").SetValue(version)
|
app.config.Section("jellyfin").Key("version").SetValue(version)
|
||||||
app.config.Section("jellyfin").Key("device").SetValue("jfa-go")
|
app.config.Section("jellyfin").Key("device").SetValue("jfa-go")
|
||||||
app.config.Section("jellyfin").Key("device_id").SetValue(fmt.Sprintf("jfa-go-%s-%s", version, commit))
|
app.config.Section("jellyfin").Key("device_id").SetValue(fmt.Sprintf("jfa-go-%s-%s", version, commit))
|
||||||
|
|
||||||
|
// These two settings are pretty much the same
|
||||||
|
url1 := app.config.Section("invite_emails").Key("url_base").String()
|
||||||
|
url2 := app.config.Section("password_resets").Key("url_base").String()
|
||||||
|
app.MustSetValue("password_resets", "url_base", strings.TrimSuffix(url1, "/invite"))
|
||||||
|
app.MustSetValue("invite_emails", "url_base", url2)
|
||||||
|
|
||||||
messagesEnabled = app.config.Section("messages").Key("enabled").MustBool(false)
|
messagesEnabled = app.config.Section("messages").Key("enabled").MustBool(false)
|
||||||
telegramEnabled = app.config.Section("telegram").Key("enabled").MustBool(false)
|
telegramEnabled = app.config.Section("telegram").Key("enabled").MustBool(false)
|
||||||
discordEnabled = app.config.Section("discord").Key("enabled").MustBool(false)
|
discordEnabled = app.config.Section("discord").Key("enabled").MustBool(false)
|
||||||
|
@ -803,6 +803,15 @@
|
|||||||
"value": false,
|
"value": false,
|
||||||
"description": "Instead of automatically setting the user's password to the PIN, allow them to set a new password through the reset link."
|
"description": "Instead of automatically setting the user's password to the PIN, allow them to set a new password through the reset link."
|
||||||
},
|
},
|
||||||
|
"url_base": {
|
||||||
|
"name": "URL Base",
|
||||||
|
"required": true,
|
||||||
|
"requires_restart": false,
|
||||||
|
"depends_true": "link_reset",
|
||||||
|
"type": "text",
|
||||||
|
"value": "http://accounts.jellyf.in:8056",
|
||||||
|
"description": "Base URL for jfa-go. You can leave this if you have one set in \"Invite Emails\". This is necessary because using a reverse proxy means the program has no way of knowing the URL itself."
|
||||||
|
},
|
||||||
"language": {
|
"language": {
|
||||||
"name": "Default reset link language",
|
"name": "Default reset link language",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -896,7 +905,7 @@
|
|||||||
"requires_restart": false,
|
"requires_restart": false,
|
||||||
"depends_true": "enabled",
|
"depends_true": "enabled",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"value": "http://accounts.jellyf.in:8056/invite",
|
"value": "http://accounts.jellyf.in:8056",
|
||||||
"description": "Base URL for jfa-go. This is necessary because using a reverse proxy means the program has no way of knowing the URL itself."
|
"description": "Base URL for jfa-go. This is necessary because using a reverse proxy means the program has no way of knowing the URL itself."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
email.go
11
email.go
@ -369,6 +369,9 @@ func (emailer *Emailer) inviteValues(code string, invite Invite, app *appContext
|
|||||||
d, t, expiresIn := emailer.formatExpiry(expiry, false, app.datePattern, app.timePattern)
|
d, t, expiresIn := emailer.formatExpiry(expiry, false, app.datePattern, app.timePattern)
|
||||||
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", inviteLink, code)
|
inviteLink = fmt.Sprintf("%s/%s", inviteLink, code)
|
||||||
template := map[string]interface{}{
|
template := map[string]interface{}{
|
||||||
"hello": emailer.lang.InviteEmail.get("hello"),
|
"hello": emailer.lang.InviteEmail.get("hello"),
|
||||||
@ -540,17 +543,17 @@ func (emailer *Emailer) resetValues(pwr PasswordReset, app *appContext, noSub bo
|
|||||||
} else {
|
} else {
|
||||||
template["helloUser"] = emailer.lang.Strings.template("helloUser", tmpl{"username": pwr.Username})
|
template["helloUser"] = emailer.lang.Strings.template("helloUser", tmpl{"username": pwr.Username})
|
||||||
template["codeExpiry"] = emailer.lang.PasswordReset.template("codeExpiry", tmpl{"date": d, "time": t, "expiresInMinutes": expiresIn})
|
template["codeExpiry"] = emailer.lang.PasswordReset.template("codeExpiry", tmpl{"date": d, "time": t, "expiresInMinutes": expiresIn})
|
||||||
inviteLink := app.config.Section("invite_emails").Key("url_base").String()
|
url := app.config.Section("password_resets").Key("url_base").String()
|
||||||
if linkResetEnabled {
|
if linkResetEnabled {
|
||||||
if inviteLink != "" {
|
if url != "" {
|
||||||
// Strip /invite form end of this URL, ik its ugly.
|
// Strip /invite form end of this URL, ik its ugly.
|
||||||
template["link_reset"] = true
|
template["link_reset"] = true
|
||||||
pinLink := fmt.Sprintf("%s/reset?pin=%s", strings.TrimSuffix(inviteLink, "/invite"), pwr.Pin)
|
pinLink := fmt.Sprintf("%s/reset?pin=%s", url, pwr.Pin)
|
||||||
template["pin"] = pinLink
|
template["pin"] = pinLink
|
||||||
// Only used in html email.
|
// Only used in html email.
|
||||||
template["pin_code"] = pwr.Pin
|
template["pin_code"] = pwr.Pin
|
||||||
} else {
|
} else {
|
||||||
app.info.Println("Password Reset link disabled as no URL Base provided. Set in Settings > Invite Emails.")
|
app.info.Println("Password Reset link disabled as no URL Base provided. Set in Settings > Password Resets.")
|
||||||
template["pin"] = pwr.Pin
|
template["pin"] = pwr.Pin
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user