1 import { Injectable } from '@angular/core';
2 import { sdc2Config } from './../../../main';
3 import {IAppConfigurtaion, ICookie} from "../../models/app-config";
4 import {Response, Headers, RequestOptions, Http} from '@angular/http';
5 import {Cookie2Service} from "./cookie.service";
6 import { Observable } from 'rxjs/Observable';
9 export class AuthenticationService {
11 private cookieService:Cookie2Service;
14 constructor(cookieService:Cookie2Service, http: Http) {
15 this.cookieService = cookieService;
19 private getAuthHeaders():any {
20 let cookie:ICookie = sdc2Config.cookie;
21 let authHeaders:any = {};
22 authHeaders[cookie.userFirstName] = this.cookieService.getFirstName();
23 authHeaders[cookie.userLastName] = this.cookieService.getLastName();
24 authHeaders[cookie.userEmail] = this.cookieService.getEmail();
25 authHeaders[cookie.userIdSuffix] = this.cookieService.getUserId();
29 public authenticate(): Observable<JSON> {
30 let options = new RequestOptions({
31 headers: new Headers(this.getAuthHeaders())
34 let authUrl = sdc2Config.api.root + sdc2Config.api.GET_user_authorize;
36 .get(authUrl, options)
37 .map((res: Response) => res.json());