Can't sign up with email domain that is automatically matched to group

(Gergely Imreh) #1

Hi, I’m administering a Discourse install hosted by Discourse. Just migrated here from another hosting.

I have a group, which also has the automatic email domain matching (Users who register with an email domain that exactly matches one in this list will be automatically added to this group). The problem I face is that now if people are signing up from the domain I set there, they receive a Password is the same as your current password. error and the system won’t let them sign up. Other domains are fine, and if I take out the domain from the group settings, the same email address can sign up perfectly fine.

Here’s what I see when trying to sign up: showing that there’s no such email nor username in use, but still get a password error. The password was a random string.

So the steps:

  • Create group
  • For that group set Users who register with an email domain that exactly matches one in this list will be automatically added to this group: to a specific domain
  • Try to sign up with an email address using that domain

What should happen:

  • Sign up fine

What happens:

  • Password is the same as your current password. error and back to create new account screen

Any idea what might be going wrong here?

(Jeff Atwood) #2

Well that’s odd @neil how can a new account be triggering this?

(Neil Lalonde) #3

Hmm when I test it I see an error on the server with stack like this:

ActiveRecord::AssociationTypeMismatch - User(#70301387222720) expected, got User(#70301532555640):
  activerecord ( lib/active_record/associations/association.rb:218:in `raise_on_type_mismatch!'

  ... snip ...

  activerecord ( lib/active_record/persistence.rb:50:in `create!'
  app/services/group_action_logger.rb:28:in `log_add_user_to_group'
  app/models/user.rb:934:in `block in automatic_group_membership'
  activerecord ( lib/active_record/relation/delegation.rb:46:in `each'
  app/models/user.rb:930:in `automatic_group_membership'

Something broke recently, maybe related to the new group features? I can look more tomorrow.

(Neil Lalonde) #4

I can’t reproduce the problem at all today… Also I notice in your screenshot that the password field has a validation error “That password is too common”. Is it a good password?

(Gergely Imreh) #5

As mentioned above, the password is a random string. Before hitting sing-up, the form says "Your password looks good. If I put in an email address that is not connected to the group, the signup accepts it without a problem, so the password itself does not seem to be the issue.

From the screenshot the weird thing is how is it possible to hit “Password is the same as your current password.” with a not-yet existing account?

We are hosting with Discourse, can check this out on the actual forum, just let me know if you’d like more info. Also, it was working on the previous hosting, which was using Discourse 1.6 before we migrated (for more context).

(Neil Lalonde) #6

I fixed this one today. It can happen when the group also grants a trust level. The password was being validated twice, causing the error about the password being the same as your current password. I’m sure at least one other site has been doing this for a long time, but… it was broken. /shrug

(Jeff Atwood) #7

(Alan Tan) #8

(Alan Tan) #9

Unfortunately, I have to revert the fix first before we can figure out the right fix. The current fix causes an extra query to run whenever a user record is initialize and it is hurting performance on any routes that renders a list of users.

(Alan Tan) #10

Fixed in

(Alan Tan) #11