Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Observable } from 'rxjs/Observable';
- import { AngularFireAuth } from 'angularfire2/auth';
- import * as firebase from 'firebase/app';
- @Injectable()
- export class AuthService {
- public user : Observable<firebase.User>;
- private auth;
- constructor( public afAuth: AngularFireAuth )
- {
- this.user = afAuth.authState;
- this.auth = firebase.auth();
- }
- login() {
- this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
- }
- logout() {
- this.afAuth.auth.signOut();
- }
- register(email:any, password:any)
- {
- console.log('xx');
- console.log(email);
- let promise = this.auth.createUserWithEmailAndPassword(email, password);
- promise.catch( e => {
- console.log(e);
- });
- this.auth.onAuthStateChanged(firebaseUser =>{
- if( firebaseUser )
- {
- console.log(firebaseUser);
- }else{
- console.log(firebaseUser);
- }
- } );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement