1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-18 12:54:27 +01:00

[bug] fix duplicates email on case sensitive matches

This commit is contained in:
Sylvain 2021-12-21 11:20:44 +01:00
parent 90b1e98938
commit 9173bdbcb4

View File

@ -79,17 +79,17 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def username_exists?(username, exclude_id = nil)
if exclude_id.nil?
User.where(username: username).size.positive?
User.where('lower(username) = ?', username.downcase).size.positive?
else
User.where(username: username).where.not(id: exclude_id).size.positive?
User.where('lower(username) = ?', username.downcase).where.not(id: exclude_id).size.positive?
end
end
def email_exists?(email, exclude_id = nil)
if exclude_id.nil?
User.where(email: email).size.positive?
User.where('lower(email) = ?', email.downcase).size.positive?
else
User.where(email: email).where.not(id: exclude_id).size.positive?
User.where('lower(email) = ?', email.downcase).where.not(id: exclude_id).size.positive?
end
end