mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
Simplify a method to remove Rubocop violation
This commit is contained in:
parent
cf16aa4039
commit
98f55fd48a
1 changed files with 7 additions and 13 deletions
|
@ -34,20 +34,14 @@ module Versions
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_from_id_role_username(str)
|
def user_from_id_role_username(str)
|
||||||
if str.match(/^(\d+)-(ApiUser:|api-)/)
|
|
||||||
user = ApiUser.find_by(id: $1)
|
|
||||||
end
|
|
||||||
unless user.present?
|
|
||||||
user = if str.match(/^(\d+)-AdminUser:/)
|
|
||||||
AdminUser.find_by(id: $1)
|
|
||||||
end
|
|
||||||
unless user.present?
|
|
||||||
# on import we copied Registrar name, which may eql code
|
|
||||||
registrar = Registrar.find_by(name: str)
|
registrar = Registrar.find_by(name: str)
|
||||||
# assume each registrar has only one user
|
|
||||||
user = registrar.api_users.first if registrar
|
user = registrar.api_users.first if registrar
|
||||||
|
str_match = str.match(/^(\d+)-(ApiUser:|api-|AdminUser:)/)
|
||||||
|
|
||||||
|
if str_match
|
||||||
|
user ||= User.find_by(id: str_match[1])
|
||||||
end
|
end
|
||||||
end
|
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue