-
-
Save geykel/b205ef48fce80c4bd3cc0b19f3e72211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { AngularFireAuth } from 'angularfire2/auth'; | |
import { User, Promise } from 'firebase/app'; | |
import { UserModel } from '../models/user-model'; | |
@Injectable() | |
export class AuthService { | |
user: User; | |
constructor(public angularFireAuth: AngularFireAuth) { | |
angularFireAuth.authState.subscribe((user: User) => { | |
this.user = user; | |
}); | |
} | |
get authenticated(): boolean { | |
return this.user != null; | |
} | |
signInWithEmailAndPassword(userModel: UserModel): Promise<any> { | |
return this.angularFireAuth.auth.signInWithEmailAndPassword(userModel.email, userModel.password); | |
} | |
createUserWithEmailAndPassword(userModel: UserModel): Promise<any> { | |
return this.angularFireAuth.auth.createUserWithEmailAndPassword(userModel.email, userModel.password); | |
} | |
signOut(): Promise<any> { | |
return this.angularFireAuth.auth.signOut(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment