<commit_before>import { Http, Headers, RequestOptions, Response, ResponseContentType } from '@angular/http';
import { Injectable } from '@angular/core';

import { ErrorHandler } from './http-errors'

import { environment } from '../../../environments/environment';

@Injectable()
export class AuthService {
  loggedIn = false;
  redirectLoginUrl = '/login';

  baseURL: string = environment.baseURL;
  loginURL: string = environment.loginURL;

  clientID: string = environment.clientID;
  clientSecret: string = environment.clientSecret;
  callbackURL: string = environment.callbackURL;

  authCode: string;
  token: string;

  state: string = '';
  scope: string = '';

  apiKey: string;

  constructor(public http: Http) { }

  createLoginURL() {
    return this.loginURL
          + "?response_type=code"
          + "&client_id="     +encodeURIComponent(this.clientID)
          + "&state="         +encodeURIComponent(this.state)
          + "&redirect_uri="  +encodeURIComponent(this.callbackURL)
          + "&scope="         +encodeURIComponent(this.scope);
  };

  isLoggedIn(): boolean {
    return this.loggedIn;
  }

  initiateLogin(): void {
    location.href = this.createLoginURL();
  }

  login(callback: any): void {
    this.pullToken();
    this.loggedIn = true;
    callback();
  }

  initiateLogout(): void {
    this.logout();
  }

  logout(): void {
    this.loggedIn = false;
  }

  callback(code: string): void {
    this.authCode = code;
  }

  buildHeader(): Headers {
    return new Headers({
        'Accept': 'application/json'
      });
  }

  buildOptions(headers: Headers): RequestOptions {
    return new RequestOptions({ headers: headers });
  }<commit_msg>Support login/logout event emissions<commit_after>import { Http, Headers, RequestOptions, Response, ResponseContentType } from '@angular/http';
import { Injectable, EventEmitter } from '@angular/core';

import { ErrorHandler } from './http-errors'

import { environment } from '../../../environments/environment';

@Injectable()
export class AuthService {
  loginStatus:EventEmitter<any> = new EventEmitter();

  loggedIn = false;
  redirectLoginUrl = '/login';

  baseURL: string = environment.baseURL;
  loginURL: string = environment.loginURL;

  clientID: string = environment.clientID;
  clientSecret: string = environment.clientSecret;
  callbackURL: string = environment.callbackURL;

  authCode: string;
  token: string;

  state: string = '';
  scope: string = '';

  apiKey: string;

  constructor(public http: Http) { }

  createLoginURL() {
    return this.loginURL
          + "?response_type=code"
          + "&client_id="     +encodeURIComponent(this.clientID)
          + "&state="         +encodeURIComponent(this.state)
          + "&redirect_uri="  +encodeURIComponent(this.callbackURL)
          + "&scope="         +encodeURIComponent(this.scope);
  };

  isLoggedIn(): boolean {
    return this.loggedIn;
  }

  initiateLogin(): void {
    location.href = this.createLoginURL();
  }

  login(callback: any): void {
    this.loginStatus.emit("true");
    this.pullToken();
    this.loggedIn = true;
    callback();
  }

  initiateLogout(): void {
    this.logout();
  }

  logout(): void {
    this.loginStatus.emit("false")
    this.loggedIn = false;
  }

  callback(code: string): void {
    this.authCode = code;
  }

  buildHeader(): Headers {
    return new Headers({
        'Accept': 'application/json'
      });
  }

  buildOptions(headers: Headers): RequestOptions {
    return new RequestOptions({ headers: headers });
  }
{'fraction_non_alphanumeric': 0.13649182177100957, 'fraction_numerical': 0.0, 'mean_word_length': 3.2479041916167666, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1671247', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1074, 'n_words': 229}