import { Injectable, EventEmitter } from '@angular/core';
import { HttpHeaders, HttpClient } from '@angular/common/http';
import { Router } from '@angular/router';
import { AuthService } from '../auth.service';
import { environment } from '../../environments/environment';
const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type': 'application/json'
  })
};


@Injectable({ providedIn: 'root' })

export class LoginService {

  baseurl: string

  constructor(private http: HttpClient) { }



  sendemail(email: string) {
    this.baseurl = environment.serviceUrl;
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.http.post(this.baseurl + 'api/UserApi/sendemail/' + email, { email }, { headers: header, observe: 'response' });
  }

  login(emailid: string, password: string, loggedinflag: number) {

    this.baseurl = environment.serviceUrl;
    return this.http.post(this.baseurl + 'api/UserApi/authenticate', { emailid, password, loggedinflag });
  }

  logout() {
    // remove user from local storage to log user out
    localStorage.removeItem('currentUser');
  }


}
