Skip to content

Commit

Permalink
introduce case insensitive authentication by email, closes #1261
Browse files Browse the repository at this point in the history
Supported ORMS: activerecord, datamapper, minirecord, mongoid, mongomapper, sequel
ORMs not supporting case insensitive search: ohm
Cryptic ORMS: couchrest
  • Loading branch information
ujifgc committed Jul 9, 2013
1 parent 86c1979 commit 8b2d2c0
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Expand Up @@ -19,7 +19,7 @@ class <%= @model_name %> < ActiveRecord::Base
# This method is for authentication purpose
#
def self.authenticate(email, password)
account = first(:conditions => { :email => email }) if email.present?
account = first(:conditions => ["lower(email) = lower(?)", email]) if email.present?
account && account.has_password?(password) ? account : nil
end

Expand Down
Expand Up @@ -29,7 +29,7 @@ class <%= @model_name %>
# This method is for authentication purpose
#
def self.authenticate(email, password)
account = first(:conditions => { :email => email }) if email.present?
account = first(:conditions => ["lower(email) = lower(?)", email]) if email.present?
account && account.has_password?(password) ? account : nil
end

Expand Down
Expand Up @@ -22,7 +22,7 @@ class <%= @model_name %> < ActiveRecord::Base
# This method is for authentication purpose
#
def self.authenticate(email, password)
account = first(:conditions => { :email => email }) if email.present?
account = first(:conditions => ["lower(email) = lower(?)", email]) if email.present?
account && account.has_password?(password) ? account : nil
end

Expand Down
Expand Up @@ -27,7 +27,7 @@ class <%= @model_name %>
# This method is for authentication purpose
#
def self.authenticate(email, password)
account = where(:email => email).first if email.present?
account = where(:email => /#{Regexp.escape(email)}/i).first if email.present?
account && account.has_password?(password) ? account : nil
end

Expand Down
Expand Up @@ -27,7 +27,7 @@ class <%= @model_name %>
# This method is for authentication purpose
#
def self.authenticate(email, password)
account = first(:email => email) if email.present?
account = first(:email => /#{Regexp.escape(email)}/i) if email.present?
account && account.has_password?(password) ? account : nil
end

Expand Down
Expand Up @@ -26,7 +26,7 @@ class <%= @model_name %> < Sequel::Model
# This method is for authentication purpose
#
def self.authenticate(email, password)
account = filter(:email => email).first
account = filter(Sequel.function(:lower, :email) => Sequel.function(:lower, email)).first
account && account.has_password?(password) ? account : nil
end

Expand Down

0 comments on commit 8b2d2c0

Please sign in to comment.