Validate main PHP sessions against user IDs

Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
2026-07-13 08:03:07 +08:00
parent 683645be8e
commit 16ab2549d7
5 changed files with 58 additions and 14 deletions
+9 -6
View File
@@ -53,15 +53,18 @@ func New(ctx *gin.Context) *Session {
ss.UserEng = db.UserEng.NewSession()
ss.UserEng.Begin()
userID := ctx.GetString("userid")
if userID != "" {
ss.UserPref = ss.GetUserPref(userID)
ss.UserID = ss.UserPref.UserID
}
return ss
}
func (ss *Session) LoadUser(userID string) {
ss.UserPref = ss.GetUserPref(userID)
ss.UserID = ss.UserPref.UserID
}
func (ss *Session) Done() bool {
return ss.done
}
func Get(ctx *gin.Context) *Session {
return ctx.MustGet("session").(*Session)
}