This reverts commit 7398451030.
Этот коммит содержится в:
@@ -280,10 +280,10 @@ type AppIface interface {
|
||||
SessionHasPermissionToManageBot(session model.Session, botUserId string) *model.AppError
|
||||
// SessionIsRegistered determines if a specific session has been registered
|
||||
SessionIsRegistered(session model.Session) bool
|
||||
// SetSessionExpireInHours sets the session's expiry the specified number of days
|
||||
// SetSessionExpireInDays sets the session's expiry the specified number of days
|
||||
// relative to either the session creation date or the current time, depending
|
||||
// on the `ExtendSessionOnActivity` config setting.
|
||||
SetSessionExpireInHours(session *model.Session, hours int)
|
||||
SetSessionExpireInDays(session *model.Session, days int)
|
||||
// SetStatusDoNotDisturbTimed takes endtime in unix epoch format in UTC
|
||||
// and sets status of given userId to dnd which will be restored back after endtime
|
||||
SetStatusDoNotDisturbTimed(userId string, endtime int64)
|
||||
|
||||
@@ -178,7 +178,7 @@ func (a *App) DoLogin(c *request.Context, w http.ResponseWriter, r *http.Request
|
||||
session.GenerateCSRF()
|
||||
|
||||
if deviceID != "" {
|
||||
a.ch.srv.userService.SetSessionExpireInHours(session, *a.Config().ServiceSettings.SessionLengthMobileInHours())
|
||||
a.ch.srv.userService.SetSessionExpireInDays(session, *a.Config().ServiceSettings.SessionLengthMobileInDays)
|
||||
|
||||
// A special case where we logout of all other sessions with the same Id
|
||||
if err := a.RevokeSessionsForDeviceId(user.Id, deviceID, ""); err != nil {
|
||||
@@ -186,11 +186,11 @@ func (a *App) DoLogin(c *request.Context, w http.ResponseWriter, r *http.Request
|
||||
return err
|
||||
}
|
||||
} else if isMobile {
|
||||
a.ch.srv.userService.SetSessionExpireInHours(session, *a.Config().ServiceSettings.SessionLengthMobileInHours())
|
||||
a.ch.srv.userService.SetSessionExpireInDays(session, *a.Config().ServiceSettings.SessionLengthMobileInDays)
|
||||
} else if isOAuthUser || isSaml {
|
||||
a.ch.srv.userService.SetSessionExpireInHours(session, *a.Config().ServiceSettings.SessionLengthSSOInHours())
|
||||
a.ch.srv.userService.SetSessionExpireInDays(session, *a.Config().ServiceSettings.SessionLengthSSOInDays)
|
||||
} else {
|
||||
a.ch.srv.userService.SetSessionExpireInHours(session, *a.Config().ServiceSettings.SessionLengthWebInHours())
|
||||
a.ch.srv.userService.SetSessionExpireInDays(session, *a.Config().ServiceSettings.SessionLengthWebInDays)
|
||||
}
|
||||
|
||||
ua := uasurfer.Parse(r.UserAgent())
|
||||
|
||||
@@ -371,7 +371,7 @@ func (a *App) newSession(appName string, user *model.User) (*model.Session, *mod
|
||||
// Set new token an session
|
||||
session := &model.Session{UserId: user.Id, Roles: user.Roles, IsOAuth: true}
|
||||
session.GenerateCSRF()
|
||||
a.ch.srv.userService.SetSessionExpireInHours(session, *a.Config().ServiceSettings.SessionLengthSSOInHours())
|
||||
a.ch.srv.userService.SetSessionExpireInDays(session, *a.Config().ServiceSettings.SessionLengthSSOInDays)
|
||||
session.AddProp(model.SessionPropPlatform, appName)
|
||||
session.AddProp(model.SessionPropOs, "OAuth2")
|
||||
session.AddProp(model.SessionPropBrowser, "OAuth2")
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
session.UserId = model.NewId()
|
||||
session.Token = model.NewId()
|
||||
session.Roles = model.SystemUserRoleId
|
||||
th.App.SetSessionExpireInHours(session, 24)
|
||||
th.App.SetSessionExpireInDays(session, 1)
|
||||
|
||||
var err *model.AppError
|
||||
session, err = th.App.CreateSession(session)
|
||||
@@ -111,7 +111,7 @@ func TestOAuthDeleteApp(t *testing.T) {
|
||||
session.Token = model.NewId()
|
||||
session.Roles = model.SystemUserRoleId
|
||||
session.IsOAuth = true
|
||||
th.App.ch.srv.userService.SetSessionExpireInHours(session, 24)
|
||||
th.App.ch.srv.userService.SetSessionExpireInDays(session, 1)
|
||||
|
||||
session, _ = th.App.CreateSession(session)
|
||||
|
||||
|
||||
@@ -15038,9 +15038,9 @@ func (a *OpenTracingAppLayer) SetSearchEngine(se *searchengine.Broker) {
|
||||
a.app.SetSearchEngine(se)
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SetSessionExpireInHours(session *model.Session, hours int) {
|
||||
func (a *OpenTracingAppLayer) SetSessionExpireInDays(session *model.Session, days int) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SetSessionExpireInHours")
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SetSessionExpireInDays")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
@@ -15050,7 +15050,7 @@ func (a *OpenTracingAppLayer) SetSessionExpireInHours(session *model.Session, ho
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
a.app.SetSessionExpireInHours(session, hours)
|
||||
a.app.SetSessionExpireInDays(session, days)
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SetStatusAwayIfNeeded(userID string, manual bool) {
|
||||
|
||||
@@ -239,7 +239,7 @@ func (a *App) UpdateLastActivityAtIfNeeded(session model.Session) {
|
||||
|
||||
a.UpdateWebConnUserActivity(session, now)
|
||||
|
||||
if now-session.LastActivityAt < model.SessionActivityTimeoutMiliseconds {
|
||||
if now-session.LastActivityAt < model.SessionActivityTimeout {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -321,22 +321,22 @@ func (a *App) GetSessionLengthInMillis(session *model.Session) int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var hours int
|
||||
var days int
|
||||
if session.IsMobileApp() {
|
||||
hours = *a.Config().ServiceSettings.SessionLengthMobileInHours()
|
||||
days = *a.Config().ServiceSettings.SessionLengthMobileInDays
|
||||
} else if session.IsSSOLogin() {
|
||||
hours = *a.Config().ServiceSettings.SessionLengthSSOInHours()
|
||||
days = *a.Config().ServiceSettings.SessionLengthSSOInDays
|
||||
} else {
|
||||
hours = *a.Config().ServiceSettings.SessionLengthWebInHours()
|
||||
days = *a.Config().ServiceSettings.SessionLengthWebInDays
|
||||
}
|
||||
return int64(hours * 60 * 60 * 1000)
|
||||
return int64(days * 24 * 60 * 60 * 1000)
|
||||
}
|
||||
|
||||
// SetSessionExpireInHours sets the session's expiry the specified number of days
|
||||
// SetSessionExpireInDays sets the session's expiry the specified number of days
|
||||
// relative to either the session creation date or the current time, depending
|
||||
// on the `ExtendSessionOnActivity` config setting.
|
||||
func (a *App) SetSessionExpireInHours(session *model.Session, hours int) {
|
||||
a.ch.srv.userService.SetSessionExpireInHours(session, hours)
|
||||
func (a *App) SetSessionExpireInDays(session *model.Session, days int) {
|
||||
a.ch.srv.userService.SetSessionExpireInDays(session, days)
|
||||
}
|
||||
|
||||
func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
|
||||
@@ -425,7 +425,7 @@ func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Sessio
|
||||
} else {
|
||||
session.AddProp(model.SessionPropIsGuest, "false")
|
||||
}
|
||||
a.ch.srv.userService.SetSessionExpireInHours(session, model.SessionUserAccessTokenExpiryHours)
|
||||
a.ch.srv.userService.SetSessionExpireInDays(session, model.SessionUserAccessTokenExpiry)
|
||||
|
||||
session, nErr = a.Srv().Store.Session().Save(session)
|
||||
if nErr != nil {
|
||||
|
||||
@@ -199,14 +199,14 @@ func (us *UserService) RevokeAccessToken(token string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetSessionExpireInHours sets the session's expiry the specified number of days
|
||||
// SetSessionExpireInDays sets the session's expiry the specified number of days
|
||||
// relative to either the session creation date or the current time, depending
|
||||
// on the `ExtendSessionOnActivity` config setting.
|
||||
func (us *UserService) SetSessionExpireInHours(session *model.Session, hours int) {
|
||||
func (us *UserService) SetSessionExpireInDays(session *model.Session, days int) {
|
||||
if session.CreateAt == 0 || *us.config().ServiceSettings.ExtendSessionLengthWithActivity {
|
||||
session.ExpiresAt = model.GetMillis() + (1000 * 60 * 60 * int64(hours))
|
||||
session.ExpiresAt = model.GetMillis() + (1000 * 60 * 60 * 24 * int64(days))
|
||||
} else {
|
||||
session.ExpiresAt = session.CreateAt + (1000 * 60 * 60 * int64(hours))
|
||||
session.ExpiresAt = session.CreateAt + (1000 * 60 * 60 * 24 * int64(days))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestSetSessionExpireInDays(t *testing.T) {
|
||||
CreateAt: create,
|
||||
ExpiresAt: model.GetMillis() + dayInMillis,
|
||||
}
|
||||
th.service.SetSessionExpireInHours(session, tt.days*24)
|
||||
th.service.SetSessionExpireInDays(session, tt.days)
|
||||
|
||||
// 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.SetSessionExpireInHours(session, 24)
|
||||
th.service.SetSessionExpireInDays(session, 1)
|
||||
|
||||
session, _ = th.service.CreateSession(session)
|
||||
err = th.service.RevokeAccessToken(session.Token)
|
||||
|
||||
Ссылка в новой задаче
Block a user