dimanche 28 août 2016

ember - How to create a user for those who use facebook login

I'm still quite new to ember and I've created a custom user signup/login system with Firebase as the backend and the torii add-on for user authentication. I've also looked around and there's plenty of tutorials/info on how to incorporate facebook login, which I have done, however that's all it does for me right now... Log you in and give you a session, but doesn't create a user in the users database that I've set up.

Whereas if you use the custom login, it creates a user model and saves it in the users database that you can retrieve. As of right now if you try to retrieve users from the database who are logged in through facebook, it gives an error since they are not in the database, even though they have a uid assigned by firebase.

So basically right now there seem to be two different kinds of users in my app, the ones who use the custom sign up and are in the users table/database, and users who sign in using facebook, but can't really do anything but log in. How do I create a user when someone signs into my app for the first time using facebook so that they have the same capabilities as someone who uses the custom sign up?

So far I have the facebook SDK loaded in an initializer and I have a button that triggers the sign in action in a controller that passes in "facebook" as the provider.

import Ember from 'ember';

export default Ember.Controller.extend({  
  firebaseApp: Ember.inject.service(),
  session: Ember.inject.service('session'),

    actions: {
      signIn: function(provider) {
        const email = this.get('email');
        const password = this.get('password');
      this.get('session')
      .open('firebase', { provider: provider, email: email, password: password})
      .then(function(data) {
      });
    },

      signOut: function() {
        this.get('session').close();
      }

});




Aucun commentaire:

Enregistrer un commentaire