Commit a0a1c8d1 authored by Rob Colbert's avatar Rob Colbert

add ability to log in w/username or email address

accepts:
@user, user, user@domain.com
parent f30e9622
......@@ -327,4 +327,14 @@ class User < ApplicationRecord
def validate_email_dns?
email_changed? && !(Rails.env.test? || Rails.env.development?)
end
# allow username or email address for login (Gab)
def self.find_for_database_authentication conditions
if conditions[:email].start_with? "@" or !conditions[:email].include? "@"
joins(:account).find_by(accounts: { domain: nil, username: conditions[:email].sub('@', '') })
else
super
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment