mirror of
https://github.com/internetee/registry.git
synced 2025-08-16 06:23:57 +02:00
refactoring 2.0
This commit is contained in:
parent
7fbbdcb5a3
commit
8f8b97a6ba
2 changed files with 16 additions and 11 deletions
|
@ -19,23 +19,15 @@ module Repp
|
|||
desc 'Submit a new api user certificate signing request'
|
||||
def create
|
||||
@api_user = current_user.registrar.api_users.find(cert_params[:api_user_id])
|
||||
|
||||
csr = decode_cert_params(cert_params[:csr])
|
||||
|
||||
@certificate = @api_user.certificates.build(csr: csr)
|
||||
|
||||
if csr.blank?
|
||||
@certificate.errors.add(:base, I18n.t(:crt_or_csr_must_be_present))
|
||||
return handle_non_epp_errors(@certificate)
|
||||
end
|
||||
|
||||
if Rails.env.test? && cert_params[:csr][:body] != 'invalid'
|
||||
result = @certificate.save(validate: false)
|
||||
else
|
||||
result = @certificate.save
|
||||
end
|
||||
|
||||
if result
|
||||
@certificate = @api_user.certificates.build(csr: csr)
|
||||
if @certificate.save
|
||||
notify_admins
|
||||
render_success(data: { api_user: { id: @api_user.id } })
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue