0
0
Fork 0

Access tokens no longer expire, case-insensitive local username validation, as well as case-insensitive Webfinger look-up

This commit is contained in:
Eugen Rochko 2016-03-16 18:29:52 +01:00
parent 786397e15d
commit 9cb690c706
3 changed files with 15 additions and 6 deletions

View file

@ -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)