mirror of
https://github.com/hrfee/jfa-go.git
synced 2025-01-09 18:00:11 +00:00
Compare commits
No commits in common. "561c461a18b3d164786b55a996576a79fff4d0bd" and "fb6256d1ed6f5680a0e66d0ec28b316c27d8a2aa" have entirely different histories.
561c461a18
...
fb6256d1ed
2
email.go
2
email.go
@ -535,7 +535,7 @@ func (emailer *Emailer) resetValues(pwr PasswordReset, app *appContext, noSub bo
|
|||||||
if inviteLink != "" {
|
if inviteLink != "" {
|
||||||
// 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.TrimPrefix(inviteLink, "/invite"), pwr.Pin)
|
pinLink := fmt.Sprintf("%s/reset?pin=%s", strings.Replace(inviteLink, "/invite", "", 1), 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
|
||||||
|
@ -54,12 +54,10 @@ func pwrMonitor(app *appContext, watcher *fsnotify.Watcher) {
|
|||||||
var pwr PasswordReset
|
var pwr PasswordReset
|
||||||
data, err := os.ReadFile(event.Name)
|
data, err := os.ReadFile(event.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.debug.Printf("PWR: Failed to read file: %v", err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(data, &pwr)
|
err = json.Unmarshal(data, &pwr)
|
||||||
if len(pwr.Pin) == 0 || err != nil {
|
if len(pwr.Pin) == 0 || err != nil {
|
||||||
app.debug.Printf("PWR: Failed to read PIN: %v", err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.info.Printf("New password reset for user \"%s\"", pwr.Username)
|
app.info.Printf("New password reset for user \"%s\"", pwr.Username)
|
||||||
|
10
views.go
10
views.go
@ -137,7 +137,6 @@ func (app *appContext) AdminPage(gc *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *appContext) ResetPassword(gc *gin.Context) {
|
func (app *appContext) ResetPassword(gc *gin.Context) {
|
||||||
isBot := strings.Contains(gc.Request.Header.Get("User-Agent"), "Bot")
|
|
||||||
pin := gc.Query("pin")
|
pin := gc.Query("pin")
|
||||||
if pin == "" {
|
if pin == "" {
|
||||||
app.NoRouteHandler(gc)
|
app.NoRouteHandler(gc)
|
||||||
@ -152,13 +151,6 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
|
|||||||
"success": false,
|
"success": false,
|
||||||
"ombiEnabled": app.config.Section("ombi").Key("enabled").MustBool(false),
|
"ombiEnabled": app.config.Section("ombi").Key("enabled").MustBool(false),
|
||||||
}
|
}
|
||||||
defer gcHTML(gc, http.StatusOK, "password-reset.html", data)
|
|
||||||
// If it's a bot, pretend to be a success so the preview is nice.
|
|
||||||
if isBot {
|
|
||||||
app.debug.Println("PWR: Ignoring magic link visit from bot")
|
|
||||||
data["success"] = true
|
|
||||||
data["pin"] = "NO-BO-TS"
|
|
||||||
} else {
|
|
||||||
resp, status, err := app.jf.ResetPassword(pin)
|
resp, status, err := app.jf.ResetPassword(pin)
|
||||||
if status == 200 && err == nil && resp.Success {
|
if status == 200 && err == nil && resp.Success {
|
||||||
data["success"] = true
|
data["success"] = true
|
||||||
@ -166,6 +158,7 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
app.err.Printf("Password Reset failed (%d): %v", status, err)
|
app.err.Printf("Password Reset failed (%d): %v", status, err)
|
||||||
}
|
}
|
||||||
|
defer gcHTML(gc, http.StatusOK, "password-reset.html", data)
|
||||||
if app.config.Section("ombi").Key("enabled").MustBool(false) {
|
if app.config.Section("ombi").Key("enabled").MustBool(false) {
|
||||||
jfUser, status, err := app.jf.UserByName(resp.UsersReset[0], false)
|
jfUser, status, err := app.jf.UserByName(resp.UsersReset[0], false)
|
||||||
if status != 200 || err != nil {
|
if status != 200 || err != nil {
|
||||||
@ -185,7 +178,6 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
|
|||||||
}
|
}
|
||||||
app.debug.Printf("Reset password for ombi user \"%s\"", ombiUser["userName"])
|
app.debug.Printf("Reset password for ombi user \"%s\"", ombiUser["userName"])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *appContext) InviteProxy(gc *gin.Context) {
|
func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user