[CST-15074] Fixes cyclic dependency issue

This commit is contained in:
Vincenzo Mecca
2025-03-23 22:33:27 +01:00
parent c1b951b18c
commit 1316540765
15 changed files with 302 additions and 53 deletions

View File

@@ -11,7 +11,6 @@ import {
} from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import { CookieAttributes } from 'js-cookie';
import uniqBy from 'lodash/uniqBy';
import {
Observable,
of as observableOf,
@@ -39,7 +38,6 @@ import {
isNotNull,
isNotUndefined,
} from '../../shared/empty.util';
import { rendersAuthMethodType } from '../../shared/log-in/methods/log-in.methods-decorator';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
import { followLink } from '../../shared/utils/follow-link-config.model';
@@ -76,7 +74,6 @@ import {
} from './auth.actions';
import { AuthRequestService } from './auth-request.service';
import { AuthMethod } from './models/auth.method';
import { AuthMethodType } from './models/auth.method-type';
import { AuthStatus } from './models/auth-status.model';
import {
AuthTokenInfo,
@@ -84,7 +81,6 @@ import {
} from './models/auth-token-info.model';
import {
getAuthenticatedUserId,
getAuthenticationMethods,
getAuthenticationToken,
getExternalAuthCookieStatus,
getRedirectUrl,
@@ -283,7 +279,7 @@ export class AuthService {
if (status.hasSucceeded) {
return status.payload.specialGroups;
} else {
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(),[]));
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), []));
}
}),
);
@@ -591,7 +587,7 @@ export class AuthService {
* @param location - The location.
* @returns The external server redirect URL.
*/
getExternalServerRedirectUrl(origin: string, redirectRoute: string, location: string): string {
getExternalServerRedirectUrl(origin: string, redirectRoute: string, location: string): string {
const correctRedirectUrl = new URLCombiner(origin, redirectRoute).toString();
let externalServerUrl = location;
@@ -693,19 +689,4 @@ export class AuthService {
this.store.dispatch(new UnsetUserAsIdleAction());
}
}
public getAuthMethods(excludedAuthMethod?: AuthMethodType): Observable<AuthMethod[]> {
return this.store.pipe(
select(getAuthenticationMethods),
map((methods: AuthMethod[]) => methods
// ignore the given auth method if it should be excluded
.filter((authMethod: AuthMethod) => excludedAuthMethod == null || authMethod.authMethodType !== excludedAuthMethod)
.filter((authMethod: AuthMethod) => rendersAuthMethodType(authMethod.authMethodType) !== undefined)
.sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position),
),
// ignore the ip authentication method when it's returned by the backend
map((authMethods: AuthMethod[]) => uniqBy(authMethods.filter(a => a.authMethodType !== AuthMethodType.Ip), 'authMethodType')),
);
}
}