import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';

import { HttpModule, Headers } from '@angular/http';

@Injectable()
export class LoginService {

  user: Observable<firebase.User>;

  constructor(private  http: HttpModule, public afAuth: AngularFireAuth) {
    this.user = afAuth.authState;
  }

  login(email, password){
    return this.afAuth.auth.signInWithEmailAndPassword(email, password);
  }

  logout() {
    return this.afAuth.auth.signOut();
  }
}
