fix(session): Fixed the session status update logic.

- Removed the error returned when the session status is `SessionInactive`.
- Updated the `LastActive` field of the session to always record the current time.
pull/9296/head
okatu-loli 2025-08-27 19:23:15 +08:00
parent c64f899a63
commit dcf4a73e42
1 changed files with 2 additions and 4 deletions

View File

@ -25,11 +25,9 @@ func Handle(userID uint, deviceKey, ua, ip string) error {
now := time.Now().Unix()
sess, err := db.GetSession(userID, deviceKey)
if err == nil {
if sess.Status == model.SessionInactive {
return errors.WithStack(errs.SessionInactive)
}
sess.LastActive = now
// reactivate existing session if it was inactive
sess.Status = model.SessionActive
sess.LastActive = now
sess.UserAgent = ua
sess.IP = ip
return db.UpsertSession(sess)