copy keep angularfire list
Maybe Object.assign but sub itme only reference So JSON.parse(JSON.stringify(theObject))
Maybe Object.assign but sub itme only reference So JSON.parse(JSON.stringify(theObject))
authstat json <-> object import { Storage } from ‘@ionic/storage’; import { FirebaseAuthState } from ‘angularfire2’; // authstate object -> json this._auth.signInWithEmailAndPassword(this.loginForm.value.email, this.loginForm.value.password) .then((authData: FirebaseAuthState ) => { this.storage.set(‘alluserinfo’, JSON.stringify(authData)); }); //json -> authstate object this.storage.get(‘alluserinfo’).then((t_value) => { let value: FirebaseAuthState; value = JSON.parse(t_value); });
https://github.com/rodrigoreal/ionic2-angularfire-login ========== https://github.com/angular/angularfire2/issues/560 https://blog.khophi.co/angularfire2-authentication/ https://github.com/angular/angularfire2/issues/568 https://github.com/angular/angularfire2/issues/566
Very Important !! use subscribe constructor(public af: AngularFire) { af.auth.subscribe((authstate) => { console.log(authstate); authstate == null ? logout() : login(authstate.auth.displayName); }); } And Think change to Callback mode …………. ========== First : everyone use af.auth.getauth() , then check, have value is login, null is not login. But it’s mistack. Reload page, Change page AngularFire miss…… af.auth be free. Only login page can get af.auth Second: af.auth.subscribe ( ……. ) When auth check finish, run subscribe ( ….. ) This is real get auth. But Think login different First way…….. ...