PLT-349 adding team mgt to admin console
Этот коммит содержится в:
@@ -140,6 +140,24 @@ func (me SqlSessionStore) Remove(sessionIdOrToken string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (me SqlSessionStore) RemoveAllSessionsForTeam(teamId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
_, err := me.GetMaster().Exec("DELETE FROM Sessions WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId})
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlSessionStore.RemoveAllSessionsForTeam", "We couldn't remove all the sessions for the team", "id="+teamId+", err="+err.Error())
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
}()
|
||||
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (me SqlSessionStore) CleanUpExpiredSessions(userId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
|
||||
@@ -80,6 +80,29 @@ func TestSessionRemove(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionRemoveAll(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
s1 := model.Session{}
|
||||
s1.UserId = model.NewId()
|
||||
s1.TeamId = model.NewId()
|
||||
Must(store.Session().Save(&s1))
|
||||
|
||||
if rs1 := (<-store.Session().Get(s1.Id)); rs1.Err != nil {
|
||||
t.Fatal(rs1.Err)
|
||||
} else {
|
||||
if rs1.Data.(*model.Session).Id != s1.Id {
|
||||
t.Fatal("should match")
|
||||
}
|
||||
}
|
||||
|
||||
Must(store.Session().RemoveAllSessionsForTeam(s1.TeamId))
|
||||
|
||||
if rs2 := (<-store.Session().Get(s1.Id)); rs2.Err == nil {
|
||||
t.Fatal("should have been removed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionRemoveToken(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetForExport() StoreChannel {
|
||||
func (s SqlTeamStore) GetAll() StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -204,7 +204,7 @@ func (s SqlTeamStore) GetForExport() StoreChannel {
|
||||
|
||||
var data []*model.Team
|
||||
if _, err := s.GetReplica().Select(&data, "SELECT * FROM Teams"); err != nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetForExport", "We could not get all teams", err.Error())
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetAllTeams", "We could not get all teams", err.Error())
|
||||
}
|
||||
|
||||
result.Data = data
|
||||
|
||||
@@ -47,7 +47,7 @@ type TeamStore interface {
|
||||
Get(id string) StoreChannel
|
||||
GetByName(name string) StoreChannel
|
||||
GetTeamsForEmail(domain string) StoreChannel
|
||||
GetForExport() StoreChannel
|
||||
GetAll() StoreChannel
|
||||
}
|
||||
|
||||
type ChannelStore interface {
|
||||
@@ -110,6 +110,7 @@ type SessionStore interface {
|
||||
Get(sessionIdOrToken string) StoreChannel
|
||||
GetSessions(userId string) StoreChannel
|
||||
Remove(sessionIdOrToken string) StoreChannel
|
||||
RemoveAllSessionsForTeam(teamId string) StoreChannel
|
||||
UpdateLastActivityAt(sessionId string, time int64) StoreChannel
|
||||
UpdateRoles(userId string, roles string) StoreChannel
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user