Differential / accounts-entry

Meteor sign up and sign in pages
http://github.differential.com/accounts-entry/
MIT License
305 stars 189 forks source link

Display error message from Social logins #199

Open geekyme opened 10 years ago

geekyme commented 10 years ago

Hello there,

I am having trouble displaying my sign up error messages for a user social login account. I have a Accounts.validateNewUser hook that makes sure all new users (whether social login or password login) should have a unique email.

Here's my code :

// server
  Accounts.validateNewUser(function (user) {
    // email must be unique
    if(Meteor.users.find({email: user.email}).count()){
      throw new Meteor.Error(403, "This email is already taken.");
    }else{
      return true;
    }
  });

The specific use case over here is when my app has 2 forms of login: normal password & social login. Take for instance a user has sign up with abc@abc.com.

Afterwards, he attempt to sign up again with his social network account that has the same email registered: abc@abc.com. In this case, I would want to prompt the user that the email is being taken.

However I see I couldn't do that currently. accounts-entry with social logins configured with fail silently if there is already a user registered with the same email.

geekyme commented 10 years ago

I hack around the source code in social.coffee, I found that I am able to do what I want by adding an additional line before

Accounts._loginButtonsSession.errorMessage(err.reason || t9n("error.unknown"))

to become

Session.set('entryError', err.reason)
Accounts._loginButtonsSession.errorMessage(err.reason || t9n("error.unknown"))
queso commented 10 years ago

The question is, if you set the Session, we need to clean it up too. Where do we clean it up at?

geekyme commented 10 years ago

I don't know. My solution is hacky at best. I was actually hoping you have a more permanent solution to this.

On 1 Jul, 2014, at 10:47 pm, "Josh Owens" notifications@github.com wrote:

The question is, if you set the Session, we need to clean it up too. Where do we clean it up at?

— Reply to this email directly or view it on GitHub.

geekyme commented 10 years ago

Regarding this issue, I looked at some of your source code for generating the errors in the 'register' form:

https://github.com/Differential/accounts-entry/blob/master/client/views/signUp/signUp.coffee#L112-L125

They are setting entryError in the same way I am suggesting in the errors over here for the social logins:

https://github.com/Differential/accounts-entry/blob/master/client/views/social/social.coffee#L36-L41

I edited the issue title to be clearer. I'm looking for a way to show the error messages from a social login.