Skip to content

Instantly share code, notes, and snippets.

@geykel
Last active May 24, 2017 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geykel/b205ef48fce80c4bd3cc0b19f3e72211 to your computer and use it in GitHub Desktop.
Save geykel/b205ef48fce80c4bd3cc0b19f3e72211 to your computer and use it in GitHub Desktop.
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