Extract Registrar::CurrentUserController from SessionsController

#600
This commit is contained in:
Artur Beljajev 2017-10-04 01:00:24 +03:00
parent c1875ec88e
commit 787cca8e4c
9 changed files with 134 additions and 46 deletions

View file

@ -51,11 +51,6 @@ class ApiUser < User
find_by(identity_code: identity_code)
end
def all_by_identity_code(identity_code)
ApiUser.where(identity_code: identity_code)
.where("identity_code is NOT NULL and identity_code != ''").includes(:registrar)
end
end
def registrar_typeahead
@ -93,4 +88,10 @@ class ApiUser < User
md5 = OpenSSL::Digest::MD5.new(cert.to_der).to_s
certificates.api.exists?(md5: md5, common_name: cn)
end
def linked_users
self.class.where(identity_code: identity_code)
.where("identity_code is NOT NULL and identity_code != ''")
.where.not(id: id)
end
end