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

@@ -630,13 +630,18 @@ func MfaOTPRemoveAggregate(aggCreator *es_models.AggregateCreator, existing *mod
}
}
func SignOutAggregate(aggCreator *es_models.AggregateCreator, existing *model.User, agentID string) func(ctx context.Context) (*es_models.Aggregate, error) {
return func(ctx context.Context) (*es_models.Aggregate, error) {
agg, err := UserAggregateOverwriteContext(ctx, aggCreator, existing, existing.ResourceOwner, existing.AggregateID)
if err != nil {
return nil, err
func SignOutAggregates(aggCreator *es_models.AggregateCreator, existingUsers []*model.User, agentID string) func(ctx context.Context) ([]*es_models.Aggregate, error) {
return func(ctx context.Context) ([]*es_models.Aggregate, error) {
aggregates := make([]*es_models.Aggregate, len(existingUsers))
for i, existing := range existingUsers {
agg, err := UserAggregateOverwriteContext(ctx, aggCreator, existing, existing.ResourceOwner, existing.AggregateID)
if err != nil {
return nil, err
}
agg.AppendEvent(model.SignedOut, map[string]interface{}{"userAgentID": agentID})
aggregates[i] = agg
}
return agg.AppendEvent(model.SignedOut, map[string]interface{}{"userAgentID": agentID})
return aggregates, nil
}
}