Accounts.createUser without username, password and email

My application is build with React which is completely separate from Meteor. I use Asteroid to interface to Meteor which serve as backend only. I have manually create the facebook login button at front end and want to pass those data fetched from facebook to Accounts.createUser. This method asked two parameters which is not available because I have formatted like so

const data = {
	services: {
		facebook: fb
	},
	profile: {
		first_name: fb.first_name,
		last_name: fb.last_name,
	}
}

How to createUser without username and password? I’ve tried with Meteor.LoginWithFacebook but no luck

Please help

Muhaimin

1 Like

Sorry that you have to use React :wink: You can directly userId = Meteor.users.insert(...) in your method and then call Meteor.connection.setUserId(userId) on the serverr and this.setUserId(userId) on the client (not sure though if Asteroid offers this on the client).

1 Like

here is full flow of my implementation

getLogin(data) {
	if (!Accounts.findUserByEmail(data.services.facebook.email)) {
		Meteor.users.insert(data)
	} else {
		//login user as usual with facebook implementation
	}
}

which part that I have to set userId in client as well as server? Is there any event that I need to trigger? Appreciate your help

The createUser is to be used to create users with passwords. See that Passwords | Meteor API Docs is inside of the Password section.

You can try to use this: Accounts (multi-server) | Meteor API Docs

or

1 Like