MM-41211: Replaces SessionLength*InDays with SessionLength*InHours. (#19838)

* MM-41211: Replaces SessionLength[Web|Mobile|SSO]InDays with SessionLength[Web|Mobile|SSO]InHours.

* MM-41211: Clear the value of the old config settings.
Этот коммит содержится в:
Martin Kraft
2022-04-28 17:31:35 -04:00
коммит произвёл GitHub
родитель 4bc2ed3973
Коммит cb3d8f0a1c
19 изменённых файлов: 198 добавлений и 168 удалений

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

@@ -199,14 +199,14 @@ func (us *UserService) RevokeAccessToken(token string) error {
return nil
}
// SetSessionExpireInDays sets the session's expiry the specified number of days
// SetSessionExpireInHours sets the session's expiry the specified number of hours
// relative to either the session creation date or the current time, depending
// on the `ExtendSessionOnActivity` config setting.
func (us *UserService) SetSessionExpireInDays(session *model.Session, days int) {
func (us *UserService) SetSessionExpireInHours(session *model.Session, hours int) {
if session.CreateAt == 0 || *us.config().ServiceSettings.ExtendSessionLengthWithActivity {
session.ExpiresAt = model.GetMillis() + (1000 * 60 * 60 * 24 * int64(days))
session.ExpiresAt = model.GetMillis() + (1000 * 60 * 60 * int64(hours))
} else {
session.ExpiresAt = session.CreateAt + (1000 * 60 * 60 * 24 * int64(days))
session.ExpiresAt = session.CreateAt + (1000 * 60 * 60 * int64(hours))
}
}

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

@@ -54,7 +54,7 @@ func TestCache(t *testing.T) {
require.Empty(t, rkeys)
}
func TestSetSessionExpireInDays(t *testing.T) {
func TestSetSessionExpireInHours(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -91,7 +91,7 @@ func TestSetSessionExpireInDays(t *testing.T) {
CreateAt: create,
ExpiresAt: model.GetMillis() + dayInMillis,
}
th.service.SetSessionExpireInDays(session, tt.days)
th.service.SetSessionExpireInHours(session, tt.days*24)
// must be within 5 seconds of expected time.
require.GreaterOrEqual(t, session.ExpiresAt, tt.want-grace)
@@ -112,7 +112,7 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
session.UserId = model.NewId()
session.Token = model.NewId()
session.Roles = model.SystemUserRoleId
th.service.SetSessionExpireInDays(session, 1)
th.service.SetSessionExpireInHours(session, 24)
session, _ = th.service.CreateSession(session)
err = th.service.RevokeAccessToken(session.Token)