adriancarriger / angularfire2-offline

🔌 A simple wrapper for AngularFire2 to read and write to Firebase while offline, even after a complete refresh.
https://angularfire2-offline.firebaseapp.com/
MIT License
207 stars 48 forks source link

AngularFire2 Authentification #43

Open JaneDawson opened 7 years ago

JaneDawson commented 7 years ago

Thank you for this fantastic module!

How would you deal with the authentification to get the current user Id? Would you somehow have to add offline support for it, as well? Up to now I used AngularFireAuth ( import { AngularFireAuth } from 'angularfire2/auth'; ).

Thanks and best regards

adriancarriger commented 7 years ago

I'm not sure how you would access the current user id without it being stored on the device. I'll have to look into this more, but I can see how it would be useful. Anyone with ideas for this feature is welcome to leave feedback. Thanks!

larssn commented 7 years ago

In my humble opinion and before this grows into a monster of a module, I suggest that storing authentication info is up to the consumer. The scope of this module should simply be offline data.

The more features you add, the more features there is to maintain.

edit Re-reading this, it sounds like I was telling. Sorry! Mean to only suggest it. 😄

mparpaillon commented 7 years ago

That would be great, yes.

I guess we should have some kind of AfoAuth service. We would use it like

import { AngularFireOfflineAuth } from 'angularfire2-offline/auth';

@Injectable()
export class someService {
  constructor(private afoAuth: AngularFireOfflineAuth) {
    afoAuth.authState.subscribe(user => {
      console.log(user);
    });
  }
}

And I'm not too sure about how it would work behind the scene, but I guess in the same way as database, by storing locally the latest fetched datas and then use those datas as default before trying to fetch remote datas ?

ric-cardo commented 7 years ago

firebase already stores the auth user in localstorage