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:
@@ -23,6 +23,17 @@ type accessoryInventoryItem struct {
|
||||
WornCount int `json:"worn_count"`
|
||||
}
|
||||
|
||||
func markAccessoryUserForceRelogin(ctx *gin.Context) bool {
|
||||
if err := usermodel.MarkUserForceRelogin(db.UserEng, ctx.GetInt("userid")); err != nil {
|
||||
ctx.JSON(http.StatusOK, webuischema.Msg{
|
||||
Code: 1,
|
||||
Message: "操作成功,但登录状态刷新失败!",
|
||||
})
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func accessoryPage(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "admin/accessory.html", gin.H{
|
||||
"menu": 3,
|
||||
@@ -121,6 +132,10 @@ func addAccessory(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if !markAccessoryUserForceRelogin(ctx) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, webuischema.Msg{
|
||||
Code: 0,
|
||||
Message: "添加成功,请重新进入游戏查看!",
|
||||
@@ -322,6 +337,10 @@ func deleteAccessory(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if !markAccessoryUserForceRelogin(ctx) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, webuischema.Msg{
|
||||
Code: 0,
|
||||
Message: "删除成功,请重新登录游戏生效!",
|
||||
|
||||
Reference in New Issue
Block a user