mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
separation login from constructor JS-API
This commit is contained in:
@@ -34,6 +34,12 @@ export class AlfrescoAuthenticationService {
|
|||||||
* @param alfrescoSetting
|
* @param alfrescoSetting
|
||||||
*/
|
*/
|
||||||
constructor(public alfrescoSetting: AlfrescoSettingsService) {
|
constructor(public alfrescoSetting: AlfrescoSettingsService) {
|
||||||
|
this.alfrescoApi = new AlfrescoApi({
|
||||||
|
provider: this.alfrescoSetting.getProviders(),
|
||||||
|
ticket: this.isLoggedIn() ? this.getTicket() : null,
|
||||||
|
host: this.alfrescoSetting.ecmHost,
|
||||||
|
hostActiviti: this.alfrescoSetting.bpmHost
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,18 +59,10 @@ export class AlfrescoAuthenticationService {
|
|||||||
login(username: string, password: string) {
|
login(username: string, password: string) {
|
||||||
|
|
||||||
if (this.isLoggedIn()) {
|
if (this.isLoggedIn()) {
|
||||||
this.alfrescoApi = new AlfrescoApi({
|
|
||||||
provider: this.alfrescoSetting.getProviders(),
|
|
||||||
ticket: this.getTicket(),
|
|
||||||
host: this.alfrescoSetting.ecmHost,
|
|
||||||
hostActiviti: this.alfrescoSetting.bpmHost
|
|
||||||
});
|
|
||||||
|
|
||||||
return Observable.create((observer) => {
|
return Observable.create((observer) => {
|
||||||
observer.next({type: this.alfrescoSetting.getProviders(), ticket: this.getTicket()});
|
observer.next({type: this.alfrescoSetting.getProviders(), ticket: this.getTicket()});
|
||||||
observer.complete();
|
observer.complete();
|
||||||
}).catch(this.handleError);
|
}).catch(this.handleError);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return Observable.fromPromise(this.callApiLogin(username, password))
|
return Observable.fromPromise(this.callApiLogin(username, password))
|
||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
@@ -82,16 +80,7 @@ export class AlfrescoAuthenticationService {
|
|||||||
* @returns {*|Observable<any>}
|
* @returns {*|Observable<any>}
|
||||||
*/
|
*/
|
||||||
private callApiLogin(username: string, password: string) {
|
private callApiLogin(username: string, password: string) {
|
||||||
|
return this.alfrescoApi.login(username, password);
|
||||||
this.alfrescoApi = new AlfrescoApi({
|
|
||||||
provider: this.alfrescoSetting.getProviders(),
|
|
||||||
username: username,
|
|
||||||
password: password,
|
|
||||||
host: this.alfrescoSetting.ecmHost,
|
|
||||||
hostActiviti: this.alfrescoSetting.bpmHost
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.alfrescoApi.login();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user