diff --git a/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts b/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts index dc27be574c..b37c614ece 100644 --- a/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts +++ b/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts @@ -15,18 +15,18 @@ * limitations under the License. */ -import {AlfrescoSettingsService} from './src/services/AlfrescoSettingsService.service'; -import {AlfrescoTranslationLoader} from './src/services/AlfrescoTranslationLoader.service'; -import {AlfrescoTranslationService} from './src/services/AlfrescoTranslationService.service'; -import {AlfrescoPipeTranslate} from './src/services/AlfrescoPipeTranslate.service'; -import { AlfrescoAuthenticationService } from './src/services/alfresco-authentication.service'; +import { AlfrescoSettingsService } from './src/services/AlfrescoSettingsService.service'; +import { AlfrescoTranslationLoader } from './src/services/AlfrescoTranslationLoader.service'; +import { AlfrescoTranslationService } from './src/services/AlfrescoTranslationService.service'; +import { AlfrescoPipeTranslate } from './src/services/AlfrescoPipeTranslate.service'; +import { AlfrescoAuthenticationService } from './src/services/AlfrescoAuthenticationService.service'; export * from './src/services/AlfrescoSettingsService.service'; export * from './src/services/AlfrescoTranslationLoader.service'; export * from './src/services/AlfrescoTranslationService.service'; export * from './src/services/AlfrescoPipeTranslate.service'; export * from './src/material/MaterialDesignLiteUpgradeElement'; -export * from './src/services/alfresco-authentication.service'; +export * from './src/services/AlfrescoAuthenticationService.service'; export const ALFRESCO_CORE_PROVIDERS: [any] = [ AlfrescoAuthenticationService, diff --git a/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts similarity index 97% rename from ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts index 9dbf52f627..e3a09bed90 100644 --- a/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts @@ -19,7 +19,7 @@ import { it, describe, beforeEach } from 'angular2/testing'; import { provide, Injector } from 'angular2/core'; import { Http, HTTP_PROVIDERS, XHRBackend, Response, ResponseOptions } from 'angular2/http'; import { MockBackend } from 'angular2/http/testing'; -import { AlfrescoAuthenticationService } from './alfresco-authentication.service'; +import { AlfrescoAuthenticationService } from './AlfrescoAuthenticationService.service'; describe('AlfrescoAuthentication', () => { @@ -115,4 +115,3 @@ describe('AlfrescoAuthentication', () => { }); }); - diff --git a/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.ts similarity index 86% rename from ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.ts rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.ts index 6ba8c8535c..f841c3f5d4 100644 --- a/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.ts @@ -18,6 +18,7 @@ import { Injectable } from 'angular2/core'; import { Observable } from 'rxjs/Rx'; import { Http, Headers, Response } from 'angular2/http'; +import { AlfrescoSettingsService } from './AlfrescoSettingsService.service'; /** * The AlfrescoAuthenticationService provide the login service and store the token in the localStorage @@ -26,22 +27,25 @@ import { Http, Headers, Response } from 'angular2/http'; export class AlfrescoAuthenticationService { token: string; - private _host: string = 'http://192.168.99.100:8080'; - private _baseUrl: string = this._host + '/alfresco/api/-default-/public/authentication/versions/1'; + private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1'; /** * Constructor * @param http */ - constructor(public http: Http) { + constructor(public http: Http, private alfrescoSettingsService: AlfrescoSettingsService) { this.token = localStorage.getItem('token'); } + getBaseUrl(): string { + return this.alfrescoSettingsService.host + this._authUrl; + } + /** * The method return tru if the user is logged in * @returns {boolean} */ - isLoggedIn() { + isLoggedIn(): boolean { return !!localStorage.getItem('token'); } @@ -68,7 +72,7 @@ export class AlfrescoAuthenticationService { headers.append('Content-Type', 'application/json'); headers.append('Accept', 'application/json'); - return this.http.post(this._baseUrl + '/tickets', credentials, { + return this.http.post(this.getBaseUrl() + '/tickets', credentials, { headers: headers }) .map((res: any) => { @@ -90,7 +94,7 @@ export class AlfrescoAuthenticationService { headers.append('Content-Type', 'application/json'); headers.append('Authorization', 'Basic ' + btoa(this.token)); - return this.http.delete(this._baseUrl + '/tickets/-me-', { + return this.http.delete(this.getBaseUrl() + '/tickets/-me-', { headers: headers }) .map((res: any) => { diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts index 200cbd5e7a..33741c73fe 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts @@ -15,17 +15,17 @@ * limitations under the License. */ -import {Injectable} from 'angular2/core'; +import { Injectable } from 'angular2/core'; @Injectable() export class AlfrescoSettingsService { private _host: string = 'http://127.0.0.1:8080'; - public get host():string { + public get host(): string { return this._host; } - public set host(value:string) { + public set host(value: string) { this._host = value; }