puerile
puerile

Reputation: 643

Finding case-insensitive emails does not work in Devise

Based from the config below in initializers/devise.rb:

# Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. config.case_insensitive_keys = [:email]

What does "find a user" mean? Is it when doing:

User.find_by(email: "[email protected]")

Because that does not work and returns nil when I have a user with email "[email protected]" in the database.

Im using rails 5 and Devise 4.2.0

Upvotes: 1

Views: 706

Answers (1)

Slava.K
Slava.K

Reputation: 3080

Note that User.find_by(email: params[:email]) is case sensitive. Use User.find_for_authentication(email: params[:email]) instead. See docs

Upvotes: 2

Related Questions