Skip to content

Conversation

@davideast
Copy link
Collaborator

This PR closes:
#71, #107, #124, #112, #106.

Changelog:


createUser(creds: FirebaseCredentials): Promise<FirebaseAuthData> {
return new Promise<FirebaseAuthData>((resolve, reject) => {
this._fbRef.createUser(creds, (err, authData) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since createUser returns a promise, couldn't this be:

createUser(creds) {
  return this._fbRef.createUser(creds);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is true, the typings don't reflect that so I have to wrap it for the time being. I'll see if I can get typings updated so we can simply return from the method.

@jeffbcross
Copy link
Contributor

LGTM with a little cleanup!

@javebratt
Copy link

Whenever I use the af.auth.getAuth() anywhere in my Ionic2 app I get an error saying:

Unhandled Promise rejection: EXCEPTION: Error in :0:0 ORIGINAL EXCEPTION: TypeError: Cannot read property 'uid' of null ORIGINAL STACKTRACE: TypeError: Cannot read property 'uid' of null at Object.authDataToAuthState (http://localhost:8100/build/js/app.bundle.js:36482:23) at FirebaseSdkAuthBackend.getAuth (http://localhost:8100/build/js/app.bundle.js:36565:31) at AngularFireAuth.getAuth (http://localhost:8100/build/js/app.bundle.js:36389:34) at new MyApp (http://localhost:8100/build/js/app.bundle.js:19:17) at DebugAppView._View_MyApp_Host0.createInternal (MyApp_Host.template.js:15:21) at DebugAppView.AppView.create (http://localhost:8100/build/js/app.bundle.js:25627:21) at DebugAppView.create (http://localhost:8100/build/js/app.bundle.js:25820:44) at ComponentFactory.create (http://localhost:8100/build/js/app.bundle.js:24941:36) at http://localhost:8100/build/js/app.bundle.js:20224:44 at http://localhost:8100/build/js/app.bundle.js:20202:26

Is there something that needs to be imported? I'm trying to do this in my app.ts:

import {Component} from '@angular/core';
import {ionicBootstrap, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {TabsPage} from './pages/tabs/tabs';
import {LoginPage} from './pages/login/login';
import {IntroPage} from './pages/intro/intro';

import {FIREBASE_PROVIDERS,
  defaultFirebase,
  AngularFire,
  AuthMethods,
  AuthProviders,
  firebaseAuthConfig,
  FirebaseAuthState} from 'angularfire2';

@Component({
  template: '<ion-nav [root]="rootPage"></ion-nav>',
})
export class MyApp {
  rootPage: any;
  public fireAuth: any;

  constructor(platform: Platform, public af: AngularFire) {
    this.fireAuth = af.auth.getAuth();

    if (this.fireAuth) {
      this.rootPage = TabsPage;
    } else {
      this.rootPage = LoginPage;
    }



    platform.ready().then(() => {

      StatusBar.styleDefault();
    });
  }
}

ionicBootstrap(MyApp, [
  FIREBASE_PROVIDERS,
  defaultFirebase({
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    storageBucket: ""
  }),
  firebaseAuthConfig({
    provider: AuthProviders.Password,
    method: AuthMethods.Password,
  })
], {});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants