feat: on logout we terminate all sessions from agent (#288)

* feat: on logout we terminate all sessions from agent

* Update eventstore.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi
2020-06-29 09:49:40 +02:00
committed by GitHub
parent 509a993d31
commit 79eff2795f
5 changed files with 40 additions and 20 deletions

View File

@@ -227,8 +227,16 @@ func (repo *UserRepo) SetPassword(ctx context.Context, userID, code, password st
return repo.UserEvents.SetPassword(ctx, policy, userID, code, password)
}
func (repo *UserRepo) SignOut(ctx context.Context, agentID, userID string) error {
return repo.UserEvents.SignOut(ctx, agentID, userID)
func (repo *UserRepo) SignOut(ctx context.Context, agentID string) error {
userSessions, err := repo.View.UserSessionsByAgentID(agentID)
if err != nil {
return err
}
userIDs := make([]string, len(userSessions))
for i, session := range userSessions {
userIDs[i] = session.UserID
}
return repo.UserEvents.SignOut(ctx, agentID, userIDs)
}
func (repo *UserRepo) UserByID(ctx context.Context, id string) (*model.UserView, error) {