Manually creating a user with facebook (all server side)

HI,

I’m using Meteor 1.1 with the Restivus package. I am combing through the code and here’s a problem I can’t seem to solve. I am manually logging the user in with facebook, verifying the user and that’s all good.

The problem is that i don’t know how to create the user, if they’ve never created an account. How do I correctly create the user - all server side?

Thanks,
Patrick

use Meteor.loginWithFacebook()

and override onCreateUser hook.

Accounts.onCreateUser(function(options, user) {

});

The Meteor.loginWith<Service> method automatically creates a user if it doesn’t exist yet. As @pahans mentioned, you can customize how the user object should look like with the hook. An example for this would be to check if the user has a specific facebook ID, and set the users role to admin if it evaluates to true.

1 Like