mirror of
https://github.com/zitadel/zitadel.git
synced 2025-11-15 03:06:02 +00:00
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:
@@ -1049,17 +1049,24 @@ func (es *UserEventstore) verifyMfaOTP(otp *usr_model.OTP, code string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *UserEventstore) SignOut(ctx context.Context, agentID, userID string) error {
|
||||
user, err := es.UserByID(ctx, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repoUser := model.UserFromModel(user)
|
||||
err = es_sdk.Push(ctx, es.PushAggregates, repoUser.AppendEvents, SignOutAggregate(es.AggregateCreator(), repoUser, agentID))
|
||||
if err != nil {
|
||||
return err
|
||||
func (es *UserEventstore) SignOut(ctx context.Context, agentID string, userIDs []string) error {
|
||||
users := make([]*model.User, len(userIDs))
|
||||
for i, id := range userIDs {
|
||||
user, err := es.UserByID(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
users[i] = model.UserFromModel(user)
|
||||
}
|
||||
|
||||
es.userCache.cacheUser(repoUser)
|
||||
aggFunc := SignOutAggregates(es.AggregateCreator(), users, agentID)
|
||||
aggregates, err := aggFunc(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = es_sdk.PushAggregates(ctx, es.PushAggregates, nil, aggregates...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user