1
votes

Currently, by default if I try to use social login in meteor, it will create a new account for the user if one is not available. But I don't want that. Here's what I need :

  • When the user signup, I need to provide social signup options. When the user signup with the social account, it should come back to the app where I will present the user with a form to enter extra details. I don't want to create an account until those details are filled. I will pull the name and email from social accounts.

  • At login, if the user have already connected a social account, he will be allowed to login. Otherwise he have to signup first.

How can I implement this behavior in Meteor?

1
Why don't you want to create an account with the initial data then prompt the user to enter more details? - jonrsharpe
@jonrsharpe If I do it I need to remove the users who haven't completed the signup with a cron job. Let's say I did that. Any idea how to prevent the user from logging in automatically after social authentication? - THpubs
No, you probably don't need to do that. Why not just leave them there? Then check when an account logs in if they've entered everything that's needed and direct them to provide it if not. - jonrsharpe

1 Answers

0
votes

The way I handle this is in Account.validateNewUser

this function validates the user and returns true or false. but you can add logic to the process.

In my case, I check if the user exists by email:

social logins (except for Twitter) all create a user with email.

the function contains a user object parameter with the user account info If you do a check using Accounts.findUserByEmail(<email>) you can find if the user has been created previously.

In that case, there are 2 cases:

  • user tried to create an account with password, just return true and the rest of the user create process will prompt the user that a user already exists with this email.

  • if it's a social login, I merge the 2 user objects to make it one, keeping the original _id. then return 'true' to pass the validation process.