1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-22 09:00:10 +00:00

userpage: invalid refresh token on pw change

user has to log in again, although this is not strictly enforced, as the
standard token remains valid until its expiry.
This commit is contained in:
Harvey Tindall 2023-06-22 20:58:56 +01:00
parent 97db4d714a
commit 6adbba54ce
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2

View File

@ -603,20 +603,27 @@ func (app *appContext) ChangeMyPassword(gc *gin.Context) {
return return
} }
if app.config.Section("ombi").Key("enabled").MustBool(false) { if app.config.Section("ombi").Key("enabled").MustBool(false) {
ombiUser, status, err := app.getOmbiUser(gc.GetString("jfId")) func() {
if status != 200 || err != nil { ombiUser, status, err := app.getOmbiUser(gc.GetString("jfId"))
app.err.Printf("Failed to get user \"%s\" from ombi (%d): %v", user.Name, status, err) if status != 200 || err != nil {
respondBool(204, true, gc) app.err.Printf("Failed to get user \"%s\" from ombi (%d): %v", user.Name, status, err)
return return
} }
ombiUser["password"] = req.New ombiUser["password"] = req.New
status, err = app.ombi.ModifyUser(ombiUser) status, err = app.ombi.ModifyUser(ombiUser)
if status != 200 || err != nil { if status != 200 || err != nil {
app.err.Printf("Failed to set password for ombi user \"%s\" (%d): %v", ombiUser["userName"], status, err) app.err.Printf("Failed to set password for ombi user \"%s\" (%d): %v", ombiUser["userName"], status, err)
respondBool(204, true, gc) return
return }
} app.debug.Printf("Reset password for ombi user \"%s\"", ombiUser["userName"])
app.debug.Printf("Reset password for ombi user \"%s\"", ombiUser["userName"]) }()
}
cookie, err := gc.Cookie("user-refresh")
if err == nil {
app.invalidTokens = append(app.invalidTokens, cookie)
gc.SetCookie("refresh", "invalid", -1, "/my", gc.Request.URL.Hostname(), true, true)
} else {
app.debug.Printf("Couldn't get cookies: %s", err)
} }
respondBool(204, true, gc) respondBool(204, true, gc)
} }