fix not silent login

This commit is contained in:
eromano
2023-07-27 18:33:38 +02:00
parent 61a8cfd0c3
commit 26c217cc2d
5 changed files with 18 additions and 16 deletions

View File

@@ -19,6 +19,7 @@ import { AlfrescoApiConfig } from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { AlfrescoApiService } from '../services/alfresco-api.service';
import { StorageService } from "../common";
export function createAlfrescoApiInstance(angularAlfrescoApiService: AlfrescoApiLoaderService) {
return () => angularAlfrescoApiService.init();
@@ -28,7 +29,7 @@ export function createAlfrescoApiInstance(angularAlfrescoApiService: AlfrescoApi
providedIn: 'root'
})
export class AlfrescoApiLoaderService {
constructor(private readonly appConfig: AppConfigService, private readonly apiService: AlfrescoApiService) {}
constructor(private readonly appConfig: AppConfigService, private readonly apiService: AlfrescoApiService, private storageService: StorageService) {}
async init(): Promise<any> {
await this.appConfig.load();
@@ -53,6 +54,8 @@ export class AlfrescoApiLoaderService {
disableCsrf: this.appConfig.get<boolean>(AppConfigValues.DISABLECSRF),
withCredentials: this.appConfig.get<boolean>(AppConfigValues.AUTH_WITH_CREDENTIALS, false),
domainPrefix: this.appConfig.get<string>(AppConfigValues.STORAGE_PREFIX),
ticketEcm: this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL),
ticketBpm: this.storageService.getItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL),
oauth2: oauth
});

View File

@@ -45,7 +45,9 @@ export enum AppConfigValues {
AUTH_WITH_CREDENTIALS = 'auth.withCredentials',
APPLICATION = 'application',
STORAGE_PREFIX = 'application.storagePrefix',
NOTIFY_DURATION = 'notificationDefaultDuration'
NOTIFY_DURATION = 'notificationDefaultDuration',
CONTENT_TICKET_STORAGE_LABEL = 'ticket-ECM',
PROCESS_TICKET_STORAGE_LABEL = 'ticket-BPM'
}
// eslint-disable-next-line no-shadow

View File

@@ -34,8 +34,6 @@ export interface TicketEntry {
};
}
export const CONTENT_TICKET_STORAGE_LABEL = 'ticket-ECM';
@Injectable({
providedIn: 'root'
})
@@ -71,8 +69,8 @@ export class ContentAuth {
}
private setConfig() {
if (this.storageService.getItem(CONTENT_TICKET_STORAGE_LABEL)) {
this.setTicket(this.storageService.getItem(CONTENT_TICKET_STORAGE_LABEL));
if (this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL)) {
this.setTicket(this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL));
}
}
@@ -157,7 +155,7 @@ export class ContentAuth {
this.authentications.basicAuth.username = 'ROLE_TICKET';
this.authentications.basicAuth.password = ticket;
this.config.ticketEcm = ticket;
this.storageService.setItem(CONTENT_TICKET_STORAGE_LABEL, ticket);
this.storageService.setItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL, ticket);
this.ticket = ticket;
}
@@ -173,7 +171,7 @@ export class ContentAuth {
}
invalidateSession() {
this.storageService.removeItem(CONTENT_TICKET_STORAGE_LABEL);
this.storageService.removeItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL);
this.authentications.basicAuth.username = null;
this.authentications.basicAuth.password = null;
this.config.ticketEcm = null;

View File

@@ -22,7 +22,6 @@ import { AppConfigService, AppConfigValues } from '../../app-config/app-config.s
import { StorageService } from '../../common/services/storage.service';
import { ReplaySubject, Subject } from 'rxjs';
export const PROCESS_TICKET_STORAGE_LABEL = 'ticket-BPM';
@Injectable({
providedIn: 'root'
@@ -58,7 +57,7 @@ export class ProcessAuth {
private setConfig() {
this.ticket = undefined;
this.setTicket(this.storageService.getItem(PROCESS_TICKET_STORAGE_LABEL));
this.setTicket(this.storageService.getItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL));
}
saveUsername(username: string) {
@@ -171,13 +170,13 @@ export class ProcessAuth {
this.authentications.basicAuth.ticket = ticket;
this.authentications.basicAuth.password = null;
this.config.ticketBpm = ticket;
this.storageService.setItem(PROCESS_TICKET_STORAGE_LABEL, ticket);
this.storageService.setItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL, ticket);
this.ticket = ticket;
}
}
invalidateSession() {
this.storageService.removeItem(PROCESS_TICKET_STORAGE_LABEL);
this.storageService.removeItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL);
this.authentications.basicAuth.ticket = null;
this.authentications.basicAuth.password = null;
this.authentications.basicAuth.username = null;