mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +00:00
fix(console): list of unique v2 sessions (#9778)
This PR ensures that the list of recent sessions has no duplicate entries. To ensure the sessions are unique, we create a map using the loginName property. --------- Co-authored-by: conblem <mail@conblem.me>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, NgIterable, Output } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { AuthConfig } from 'angular-oauth2-oidc';
|
import { AuthConfig } from 'angular-oauth2-oidc';
|
||||||
import { SessionState as V1SessionState, User, UserState } from 'src/app/proto/generated/zitadel/user_pb';
|
import { SessionState as V1SessionState, User, UserState } from 'src/app/proto/generated/zitadel/user_pb';
|
||||||
@@ -52,7 +52,7 @@ export class AccountsCardComponent {
|
|||||||
protected readonly user$ = new ReplaySubject<User.AsObject>(1);
|
protected readonly user$ = new ReplaySubject<User.AsObject>(1);
|
||||||
protected readonly UserState = UserState;
|
protected readonly UserState = UserState;
|
||||||
private readonly labelpolicy = toSignal(this.userService.labelpolicy$, { initialValue: undefined });
|
private readonly labelpolicy = toSignal(this.userService.labelpolicy$, { initialValue: undefined });
|
||||||
protected readonly sessions$: Observable<V1AndV2Session[] | undefined>;
|
protected readonly sessions$: Observable<V1AndV2Session[]>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected readonly authService: AuthenticationService,
|
protected readonly authService: AuthenticationService,
|
||||||
@@ -135,7 +135,9 @@ export class AccountsCardComponent {
|
|||||||
authState: V2SessionState.ACTIVE,
|
authState: V2SessionState.ACTIVE,
|
||||||
userName: s.factors?.user?.loginName ?? '',
|
userName: s.factors?.user?.loginName ?? '',
|
||||||
})),
|
})),
|
||||||
|
map((s) => [s.loginName, s] as const),
|
||||||
toArray(),
|
toArray(),
|
||||||
|
map((sessions) => Array.from(new Map(sessions).values())), // Ensure unique loginNames
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user