import { Injectable } from '@angular/core';
import {AngularFireAuth} from 'angularfire2/auth';
import {Observable} from 'rxjs/Observable';
@Injectable()
export class AuthService {
constructor(public afAuth: AngularFireAuth) { }
// Login User
Login(email: string, password: string) {
return new Promise ((resolve, reject) => {
this.afAuth.auth.signInWithEmailAndPassword(email, password)
.then(userData => resolve(userData),
err => reject(err));
});
}
// Check User Status
getAuth() {
return this.afAuth.authState.map(user => user);
}
// Logout
Logout() {
this.afAuth.auth.signOut();
}
Register(email: string, password: string) {
return new Promise ((resolve, reject) => {
this.afAuth.auth.createUserWithEmailAndPassword(email, password)
.then(userData => resolve(userData),
err => reject(err));
});
}
}