mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[MNT-24449] Validate ticket on config initialization (#9882)
* [MNT-24449] Validate ticket on config initialization * [MNT-24449] Added unit test
This commit is contained in:
@@ -69,6 +69,11 @@ export class AlfrescoApi implements Emitter, AlfrescoApiType {
|
||||
this.storage = Storage.getInstance();
|
||||
this.storage.setDomainPrefix(config.domainPrefix);
|
||||
|
||||
this.initConfig(config);
|
||||
this.validateTicket(config);
|
||||
}
|
||||
|
||||
private initConfig(config: AlfrescoApiConfig) {
|
||||
this.config = new AlfrescoApiConfig(config);
|
||||
|
||||
this.clientsFactory();
|
||||
@@ -81,8 +86,26 @@ export class AlfrescoApi implements Emitter, AlfrescoApiType {
|
||||
this.emitBuffer('logged-in');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
private validateTicket(config: AlfrescoApiConfig) {
|
||||
if (config.ticketEcm && !this.isOauthConfiguration()) {
|
||||
if (!this.contentAuth) {
|
||||
this.contentAuth = new ContentAuth(this.config, this, this.httpClient);
|
||||
}
|
||||
this.contentAuth
|
||||
.validateTicket()
|
||||
.then((ticket) => {
|
||||
config.ticketEcm = ticket;
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.status === 401) {
|
||||
config.ticketEcm = null;
|
||||
this.initConfig(config);
|
||||
this.emitBuffer('ticket_invalidated');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private initAuth(config: AlfrescoApiConfig): void {
|
||||
|
Reference in New Issue
Block a user