mirror of
https://github.com/internetee/registry.git
synced 2025-07-19 17:25:57 +02:00
Added basic Registrant portal
This commit is contained in:
parent
90633160c0
commit
fdcad95683
28 changed files with 810 additions and 26 deletions
46
app/models/registrant_user.rb
Normal file
46
app/models/registrant_user.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
require 'open3'
|
||||
|
||||
# rubocop: disable Metrics/ClassLength
|
||||
class ApiUser < User
|
||||
include EppErrors
|
||||
def epp_code_map # rubocop:disable Metrics/MethodLength
|
||||
{
|
||||
'2306' => [ # Parameter policy error
|
||||
[:password, :blank]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
# TODO: should have max request limit per day
|
||||
belongs_to :registrar
|
||||
has_many :certificates
|
||||
|
||||
validates :username, :password, :registrar, presence: true
|
||||
validates :username, uniqueness: true
|
||||
|
||||
attr_accessor :registrar_typeahead
|
||||
|
||||
def ability
|
||||
@ability ||= Ability.new(self)
|
||||
end
|
||||
delegate :can?, :cannot?, to: :ability
|
||||
|
||||
after_initialize :set_defaults
|
||||
def set_defaults
|
||||
return unless new_record?
|
||||
self.active = true unless active_changed?
|
||||
end
|
||||
|
||||
def registrar_typeahead
|
||||
@registrar_typeahead || registrar || nil
|
||||
end
|
||||
|
||||
def to_s
|
||||
username
|
||||
end
|
||||
|
||||
def queued_messages
|
||||
registrar.messages.queued
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/ClassLength
|
Loading…
Add table
Add a link
Reference in a new issue