remove unneeded JS-API dep

move auth in the right place
This commit is contained in:
eromano
2023-03-31 12:12:02 +02:00
committed by Amedeo Lepore
parent 82ae9d53d1
commit aa69ac4d27
5 changed files with 9 additions and 68 deletions
@@ -27,7 +27,6 @@ import { ObjectDataTableAdapter, AuthenticationService } from '@alfresco/adf-cor
<li>Global i18n: {{ 'APP_LAYOUT.DATATABLE_LAZY' | translate }}</li>
<li>Local i18n (work in progress): {{ 'LAZY.TEXT' | translate }}</li>
<li>isLoggedIn: {{ isLoggedIn }}</li>
<li>ECM username: {{ username }}
</ul>
`
})
@@ -39,10 +38,6 @@ export class LazyLoadingComponent {
return this.auth.isLoggedIn();
}
get username(): string {
return this.auth.getEcmUsername();
}
constructor(private auth: AuthenticationService) {
this.data = new ObjectDataTableAdapter(
// data
@@ -87,7 +87,7 @@ export class ContentService {
*/
hasPermissions(node: Node, permission: PermissionsEnum | string, userId?: string): boolean {
let hasPermissions = false;
userId = userId ?? this.authService.getEcmUsername();
userId = userId ?? this.apiService.getInstance().getEcmUsername();
const permissions = [...(node.permissions?.locallySet || []), ...(node.permissions?.inherited || [])]
.filter((currentPermission) => currentPermission.authorityId === userId);
@@ -22,7 +22,7 @@ import { catchError, filter, map } from 'rxjs/operators';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { OauthConfigModel } from '../models/oauth-config.model';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { BaseAuthenticationService } from '../../services/base-authentication.service';
import { BaseAuthenticationService } from '../services/base-authentication.service';
import { CookieService } from '../../common/services/cookie.service';
import { JwtHelperService } from '../services/jwt-helper.service';
import { LogService } from '../../common/services/log.service';
@@ -24,8 +24,7 @@ import { AppConfigService, AppConfigValues } from '../../app-config/app-config.s
import { map, catchError, tap } from 'rxjs/operators';
import { JwtHelperService } from './jwt-helper.service';
import { StorageService } from '../../common/services/storage.service';
import { OauthConfigModel } from '../models/oauth-config.model';
import { BaseAuthenticationService } from '../../services/base-authentication.service';
import { BaseAuthenticationService } from './base-authentication.service';
@Injectable({
providedIn: 'root'
@@ -161,33 +160,6 @@ export class AuthenticationService extends BaseAuthenticationService {
return false;
}
/**
* Gets the ECM username.
*
* @returns The ECM username
*/
getEcmUsername(): string {
return this.alfrescoApi.getInstance().getEcmUsername();
}
/**
* Gets the BPM username
*
* @returns The BPM username
*/
getBpmUsername(): string {
return this.alfrescoApi.getInstance().getBpmUsername();
}
isImplicitFlow(): boolean {
const oauth2: OauthConfigModel = Object.assign({}, this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null));
return !!oauth2?.implicitFlow;
}
isAuthCodeFlow(): boolean {
return false;
}
/**
* Gets the auth token.
*
@@ -15,14 +15,13 @@
* limitations under the License.
*/
import { PeopleApi, UserProfileApi, UserRepresentation } from '@alfresco/js-api';
import { HttpHeaders } from '@angular/common/http';
import { RedirectionModel } from '../auth/models/redirection.model';
import { from, Observable, Observer, ReplaySubject, throwError } from 'rxjs';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { CookieService } from '../common/services/cookie.service';
import { LogService } from '../common/services/log.service';
import { RedirectionModel } from '../models/redirection.model';
import { Observable, Observer, ReplaySubject, throwError } from 'rxjs';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { CookieService } from '../../common/services/cookie.service';
import { LogService } from '../../common/services/log.service';
const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME';
const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30;
@@ -34,18 +33,6 @@ export abstract class BaseAuthenticationService {
onLogin = new ReplaySubject<any>(1);
onLogout = new ReplaySubject<any>(1);
_peopleApi: PeopleApi;
get peopleApi(): PeopleApi {
this._peopleApi = this._peopleApi ?? new PeopleApi(this.alfrescoApi.getInstance());
return this._peopleApi;
}
_profileApi: UserProfileApi;
get profileApi(): UserProfileApi {
this._profileApi = this._profileApi ?? new UserProfileApi(this.alfrescoApi.getInstance());
return this._profileApi;
}
constructor(
protected alfrescoApi: AlfrescoApiService,
protected appConfig: AppConfigService,
@@ -58,15 +45,11 @@ export abstract class BaseAuthenticationService {
abstract isLoggedIn(): boolean;
abstract isLoggedInWith(provider: string): boolean;
abstract isOauth(): boolean;
abstract isImplicitFlow(): boolean;
abstract isAuthCodeFlow(): boolean;
abstract login(username: string, password: string, rememberMe?: boolean): Observable<{ type: string; ticket: any }>;
abstract ssoImplicitLogin(): void;
abstract logout(): Observable<any>;
abstract isEcmLoggedIn(): boolean;
abstract isBpmLoggedIn(): boolean;
abstract getEcmUsername(): string;
abstract getBpmUsername(): string;
abstract reset(): void;
abstract once(event: string): Observable<any>;
@@ -192,15 +175,6 @@ export abstract class BaseAuthenticationService {
return null;
}
/**
* Gets information about the user currently logged into APS.
*
* @returns User information
*/
getBpmLoggedUser(): Observable<UserRepresentation> {
return from(this.profileApi.getProfile());
}
/**
* Prints an error message in the console browser
*