Created
April 25, 2017 22:42
-
-
Save NFodrea/20a1ac6bd0200de09595fbccd6324d50 to your computer and use it in GitHub Desktop.
Firebase Authentication helpers (change workout app to current app name/firebase collection)
This file contains hidden or 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
| export class AuthData { | |
| fireAuth: any; | |
| constructor(public af: AngularFire) { | |
| af.auth.subscribe( user => { | |
| if (user) { this.fireAuth = user.auth; } | |
| }); | |
| } | |
| loginUser(newEmail: string, newPassword: string): any { | |
| return this.af.auth.login({ | |
| email: newEmail, | |
| password: newPassword | |
| }); | |
| } | |
| getUser(){ | |
| return this.fireAuth; | |
| } | |
| resetPassword(email: string): any { | |
| return firebase.auth().sendPasswordResetEmail(email); | |
| } | |
| logoutUser(): any { | |
| return this.af.auth.logout(); | |
| } | |
| signupUser(newEmail: string, newPassword: string): any { | |
| return this.af.auth.createUser({ | |
| email: newEmail, | |
| password: newPassword | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment