diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index b3917e6e8..c92bb1574 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -1,7 +1,7 @@ class Account < ActiveRecord::Base # Local users has_one :user, inverse_of: :account - validates :username, uniqueness: { scope: :domain } + validates :username, uniqueness: { scope: :domain, case_sensitive: false } # Avatar upload attr_reader :avatar_remote_url @@ -97,6 +97,11 @@ class Account < ActiveRecord::Base self.username end + def self.find_local!(username) + table = self.arel_table + self.where(table[:username].matches(username)).where(domain: nil).take! + end + before_create do if local? keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 1024 : 2048) |