mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-12501] Align JS API (#8344)
* [AAE-12501] Provide an AlfrescoApiService implementation that disable the AlfrescoApi oauth initialization when we use new oidc implementation * [AAE-12501] Replace oauth2Auth with authentication service, define get username as abstract * [AAE-12501] Replace sitesService with authentication service since sitesService get the username from oauth2Auth * [AAE-12501] Call implicitLogin by authentication service * [AAE-12501] Replace Oauth2Auth with AlfrescoApi and call the custom api without using authentication * [AAE-12501] Replace oauth2Auth with authentication service to get the token * [AAE-12501] Replace oauth2Auth with alfrescoApi * remove unneeded JS-API dep move auth in the right place * [AAE-10501] Rename alfresco-api.http-client to adf-http-client * [AAE-10501] Remove config from a CoreModule, a different service is provided in AuthModule to use angular http client instead of super agent * [AAE-10501] Disable AlfrescoApi oauth initialization while using new adf oidc authentication * [AAE-12501] Replace alfresco api client with AdfHttpClient * [AAE-12501] Restore get username methods * [AAE-12501] Get username with authentication service * [AAE-12501] removee unused method * [AAE-12501] Trigger on login when token is received * [AAE-12501] Fix content-services unit test * [AAE-12501] Fix import * [AAE-12501] Fix core unit tests * [AAE-12501] Fix process-services-cloud unit tests * [AAE-12501] Create a request options interface with the needed props, remove the import from js-api, return the body from request * [AAE-12501] Fix process-services-cloud unit tests without Expectation * [AAE-12501] Fix Core secondary entrypoints unit tests are not executed: move test.ts one level up in order to find all the spec files into the secondary entrypoints folders and update path * [AAE-12501] Fix Core unit tests that weren't executed because of the previous test.ts wrong location * [AAE-12501] Fix authentication token_issued subscription * add emitters * [AAE-12501] Replace Math.random() to fix hospot security issue, fix lint issues * [AAE-12501] Install event-emitter dependency * [AAE-12501] Comment temporary setCsrfToken because is not possible to import app config service from core due to circular dependencies * [AAE-12501] Get disableCsrf from app config serviice when app configuration is loaded * [AAE-12501] Fix license-header lint issue * [AAE-14221] Regenerate lock file * [AAE-14221] Fix sonarcloud issues * [AAE-12501] Remove wrong character * [AAE-12501] Regenerate lock file * [AAE-12501] Fix BC: update alfresco api response error --------- Co-authored-by: eromano <eugenioromano16@gmail.com>
This commit is contained in:
@@ -20,7 +20,7 @@ import { from, Observable, throwError, Subject } from 'rxjs';
|
||||
import { catchError, map, switchMap, filter, take } from 'rxjs/operators';
|
||||
import { RepositoryInfo, SystemPropertiesRepresentation } from '@alfresco/js-api';
|
||||
|
||||
import { BpmProductVersionModel, AlfrescoApiService, AuthenticationService } from '@alfresco/adf-core';
|
||||
import { BpmProductVersionModel, AuthenticationService } from '@alfresco/adf-core';
|
||||
import { ApiClientsService } from '@alfresco/adf-core/api';
|
||||
|
||||
@Injectable({
|
||||
@@ -34,13 +34,12 @@ export class DiscoveryApiService {
|
||||
ecmProductInfo$ = new Subject<RepositoryInfo>();
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private authenticationService: AuthenticationService,
|
||||
private apiClientsService: ApiClientsService
|
||||
) {
|
||||
this.authenticationService.onLogin
|
||||
.pipe(
|
||||
filter(() => this.apiService.getInstance()?.isEcmLoggedIn()),
|
||||
filter(() => this.authenticationService.isEcmLoggedIn()),
|
||||
take(1),
|
||||
switchMap(() => this.getEcmProductInfo())
|
||||
)
|
||||
|
@@ -45,7 +45,8 @@ export class SitesService {
|
||||
return this._sitesApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,15 +141,6 @@ export class SitesService {
|
||||
return from(this.sitesApi.listSiteMemberships(siteId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username of the user currently logged into ACS.
|
||||
*
|
||||
* @returns Username string
|
||||
*/
|
||||
getEcmCurrentLoggedUserName(): string {
|
||||
return this.apiService.getInstance().getEcmUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for a site inside the path of a Node and returns its guid if it finds one.
|
||||
* (return an empty string if no site is found)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { AuthenticationService } from '@alfresco/adf-core';
|
||||
import moment, { Moment } from 'moment';
|
||||
|
||||
@Injectable({
|
||||
@@ -25,7 +25,7 @@ import moment, { Moment } from 'moment';
|
||||
})
|
||||
export class LockService {
|
||||
|
||||
constructor(private alfrescoApiService: AlfrescoApiService) {
|
||||
constructor(private authService: AuthenticationService) {
|
||||
}
|
||||
|
||||
isLocked(node: Node): boolean {
|
||||
@@ -34,7 +34,7 @@ export class LockService {
|
||||
if (this.isReadOnlyLock(node)) {
|
||||
isLocked = !this.isLockExpired(node);
|
||||
} else if (this.isLockOwnerAllowed(node)) {
|
||||
isLocked = this.alfrescoApiService.getInstance().getEcmUsername() !== node.properties['cm:lockOwner'].id;
|
||||
isLocked = this.authService.getEcmUsername() !== node.properties['cm:lockOwner'].id;
|
||||
if (this.isLockExpired(node)) {
|
||||
isLocked = false;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import { DebugElement } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DropdownSitesComponent, Relations } from './sites-dropdown.component';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { AuthenticationService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { of } from 'rxjs';
|
||||
import { getFakeSitePaging,
|
||||
getFakeSitePagingNoMoreItems,
|
||||
@@ -57,6 +57,7 @@ describe('DropdownSitesComponent', () => {
|
||||
let debug: DebugElement;
|
||||
let element: HTMLElement;
|
||||
let siteService: SitesService;
|
||||
let authService: AuthenticationService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -293,10 +294,11 @@ describe('DropdownSitesComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.relations = Relations.Members;
|
||||
authService = TestBed.inject(AuthenticationService);
|
||||
});
|
||||
|
||||
it('should show only sites which logged user is member of when member relation is set', (done) => {
|
||||
spyOn(siteService, 'getEcmCurrentLoggedUserName').and.returnValue('test');
|
||||
spyOn(authService, 'getEcmUsername').and.returnValue('test');
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -317,10 +319,11 @@ describe('DropdownSitesComponent', () => {
|
||||
describe('No relations', () => {
|
||||
beforeEach(() => {
|
||||
component.relations = [];
|
||||
authService = TestBed.inject(AuthenticationService);
|
||||
});
|
||||
|
||||
it('should show all the sites if no relation is set', (done) => {
|
||||
spyOn(siteService, 'getEcmCurrentLoggedUserName').and.returnValue('test');
|
||||
spyOn(authService, 'getEcmUsername').and.returnValue('test');
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { LogService, InfiniteSelectScrollDirective } from '@alfresco/adf-core';
|
||||
import { LogService, InfiniteSelectScrollDirective, AuthenticationService } from '@alfresco/adf-core';
|
||||
import { SitePaging, SiteEntry } from '@alfresco/js-api';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import {LiveAnnouncer} from '@angular/cdk/a11y';
|
||||
@@ -81,7 +81,8 @@ export class DropdownSitesComponent implements OnInit {
|
||||
selected: SiteEntry = null;
|
||||
MY_FILES_VALUE = '-my-';
|
||||
|
||||
constructor(private sitesService: SitesService,
|
||||
constructor(private authService: AuthenticationService,
|
||||
private sitesService: SitesService,
|
||||
private logService: LogService,
|
||||
private liveAnnouncer: LiveAnnouncer,
|
||||
private translateService: TranslateService) {
|
||||
@@ -174,7 +175,7 @@ export class DropdownSitesComponent implements OnInit {
|
||||
}
|
||||
|
||||
private filteredResultsByMember(sites: SitePaging): SitePaging {
|
||||
const loggedUserName = this.sitesService.getEcmCurrentLoggedUserName();
|
||||
const loggedUserName = this.authService.getEcmUsername();
|
||||
sites.list.entries = sites.list.entries.filter((site) => this.isCurrentUserMember(site, loggedUserName));
|
||||
return sites;
|
||||
}
|
||||
|
Reference in New Issue
Block a user