Update session cache if a plugin extends a session (#19178)

Этот коммит содержится в:
Ben Schumacher
2022-03-15 17:38:09 +01:00
коммит произвёл GitHub
родитель 4da98cb51a
Коммит 8d72cabee8
4 изменённых файлов: 95 добавлений и 16 удалений

Просмотреть файл

@@ -210,6 +210,20 @@ func (us *UserService) SetSessionExpireInDays(session *model.Session, days int)
}
}
func (us *UserService) ExtendSessionExpiry(session *model.Session, newExpiry int64) error {
if err := us.sessionStore.UpdateExpiresAt(session.Id, newExpiry); err != nil {
return err
}
// Update local cache. No need to invalidate cache for cluster as the session cache timeout
// ensures each node will get an extended expiry within the next 10 minutes.
// Worst case is another node may generate a redundant expiry update.
session.ExpiresAt = newExpiry
us.AddSessionToCache(session)
return nil
}
func (us *UserService) UpdateSessionsIsGuest(userID string, isGuest bool) error {
sessions, err := us.GetSessions(userID)
if err != nil {