lundi 22 mai 2017

ember firebase google login torii - help to add a custom variable

thanks for taking time to read this. I have just started using Ember and Firebase for a small private project. I am having some issues with using Google login and letting certain users have different account types than others.

What I am doing now is on a successful Google login I check for users with the same id. If it does not exist, I save the user in users with an automatically generated uid adding the desired user status, for example:

First I recover the user data from a Google login.

this.get('session').open('firebase', { provider: provider }).then((data) => {

Then if the user hasn't been saved to the database yet, I save it, with the desired custom parameter:

let newUser = this.store.createRecord('user', {
          uid: data.currentUser.uid,
          name: data.currentUser.displayName,
          email: data.currentUser.email,
          canEdit: false
        });
        newUser.save().then(() => {
            console.log('user saved');
          }).catch(error => {
            console.log('user save error', error);
          });

creating the following in firebase:

-K***********J <= create by save uid
    canEdit: false
    email: "test@test.com"
    name: "Test Test"
    uid: "9xi*************H2" <= google uid

My problem is that I am incapable of adding canEdit to the Auth object for the firebase rules nor to the currentUser that is returned by the Google login using Torii.

I do not like the idea of adding them manually later. It doesn't feel secure nor natural and it seems those changes don't bubble up to the templates to be able to use them for showing or hiding content etc.

Could someone please send me in the right direction? Any help is greatly appreciated! Please let me know if I need to explain the issue some more.

Thanks!




Aucun commentaire:

Enregistrer un commentaire