Deauthenticate websockets and set status to offline when user account deactivated (#4551)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
526c392aad
Коммит
9c36ca9aca
15
api/user.go
15
api/user.go
@@ -750,6 +750,10 @@ func RevokeSessionById(c *Context, sessionId string) {
|
||||
}
|
||||
|
||||
RevokeWebrtcToken(session.Id)
|
||||
|
||||
if einterfaces.GetClusterInterface() != nil {
|
||||
einterfaces.GetClusterInterface().RemoveAllSessionsForUserId(session.UserId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,7 +770,6 @@ func RevokeAllSession(c *Context, userId string) {
|
||||
if session.IsOAuth {
|
||||
RevokeAccessToken(session.Token)
|
||||
} else {
|
||||
sessionCache.Remove(session.Token)
|
||||
if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
@@ -776,6 +779,8 @@ func RevokeAllSession(c *Context, userId string) {
|
||||
RevokeWebrtcToken(session.Id)
|
||||
}
|
||||
}
|
||||
|
||||
RemoveAllSessionsForUserId(userId)
|
||||
}
|
||||
|
||||
// UGH...
|
||||
@@ -790,7 +795,6 @@ func RevokeAllSessionsNoContext(userId string) *model.AppError {
|
||||
if session.IsOAuth {
|
||||
RevokeAccessToken(session.Token)
|
||||
} else {
|
||||
sessionCache.Remove(session.Token)
|
||||
if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
@@ -799,6 +803,9 @@ func RevokeAllSessionsNoContext(userId string) *model.AppError {
|
||||
RevokeWebrtcToken(session.Id)
|
||||
}
|
||||
}
|
||||
|
||||
RemoveAllSessionsForUserId(userId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1590,6 +1597,10 @@ func updateActive(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if ruser, err := UpdateActive(user, active); err != nil {
|
||||
c.Err = err
|
||||
} else {
|
||||
if !active {
|
||||
SetStatusOffline(ruser.Id, false)
|
||||
}
|
||||
|
||||
c.LogAuditWithUserId(ruser.Id, fmt.Sprintf("active=%v", active))
|
||||
w.Write([]byte(ruser.ToJson()))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user