Force relogin after webui data changes

- Add a force_relogin flag to user_pref
- Return 404 for main.php requests when the user must reauthenticate
- Clear the relogin flag after successful client login
- Mark users for relogin after webui card import, accessory changes, and profile updates

Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
2026-06-13 11:29:57 +08:00
parent 6264523c76
commit 4b2c005222
6 changed files with 74 additions and 11 deletions
+16
View File
@@ -147,6 +147,14 @@ func updateProfile(ctx *gin.Context) {
return
}
if err := usermodel.MarkUserForceRelogin(db.UserEng, ctx.GetInt("userid")); err != nil {
ctx.JSON(http.StatusOK, webuischema.Msg{
Code: 1,
Message: "保存成功,但登录状态刷新失败!",
})
return
}
ctx.JSON(http.StatusOK, webuischema.Msg{
Code: 0,
Message: "保存成功!",
@@ -195,6 +203,14 @@ func resetProfile(ctx *gin.Context) {
return
}
if err := usermodel.MarkUserForceRelogin(db.UserEng, ctx.GetInt("userid")); err != nil {
ctx.JSON(http.StatusOK, webuischema.Msg{
Code: 1,
Message: "重置成功,但登录状态刷新失败!",
})
return
}
ctx.JSON(http.StatusOK, webuischema.Msg{
Code: 0,
Message: "已恢复默认值!",