Merge branch 'master' into develop-newgrid
This commit is contained in:
@@ -106,6 +106,10 @@ func (s *mockSession) Destory(c *Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *mockSession) RegenerateId(c *Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type mockLdapAuthenticator struct {
|
||||
syncSignedInUserCalled bool
|
||||
}
|
||||
|
||||
@@ -62,6 +62,15 @@ func GetContextHandler() macaron.Handler {
|
||||
ctx.Data["ctx"] = ctx
|
||||
|
||||
c.Map(ctx)
|
||||
|
||||
// update last seen at
|
||||
// update last seen every 5min
|
||||
if ctx.ShouldUpdateLastSeenAt() {
|
||||
ctx.Logger.Debug("Updating last user_seen_at", "user_id", ctx.UserId)
|
||||
if err := bus.Dispatch(&m.UpdateUserLastSeenAtCommand{UserId: ctx.UserId}); err != nil {
|
||||
ctx.Logger.Error("Failed to update last_seen_at", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +108,7 @@ func initContextWithUserSessionCookie(ctx *Context, orgId int64) bool {
|
||||
|
||||
query := m.GetSignedInUserQuery{UserId: userId, OrgId: orgId}
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
ctx.Logger.Error("Failed to get user with id", "userId", userId)
|
||||
ctx.Logger.Error("Failed to get user with id", "userId", userId, "error", err)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ type SessionStore interface {
|
||||
Destory(*Context) error
|
||||
// init
|
||||
Start(*Context) error
|
||||
// RegenerateId regenerates the session id
|
||||
RegenerateId(*Context) error
|
||||
}
|
||||
|
||||
type SessionWrapper struct {
|
||||
@@ -116,6 +118,12 @@ func (s *SessionWrapper) Start(c *Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SessionWrapper) RegenerateId(c *Context) error {
|
||||
var err error
|
||||
s.session, err = s.manager.RegenerateId(c.Context)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SessionWrapper) Set(k interface{}, v interface{}) error {
|
||||
if s.session != nil {
|
||||
return s.session.Set(k, v)
|
||||
|
||||
Reference in New Issue
Block a user