mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Registrant confirms: Poll domain change application
This commit is contained in:
parent
a182dfb3ba
commit
09389ea662
2 changed files with 57 additions and 2 deletions
55
app/controllers/api/v1/registrant/confirms_controller.rb
Normal file
55
app/controllers/api/v1/registrant/confirms_controller.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
require 'serializers/registrant_api/domain'
|
||||
|
||||
module Api
|
||||
module V1
|
||||
module Registrant
|
||||
class ConfirmsController < ::Api::V1::Registrant::BaseController
|
||||
skip_before_action :authenticate, :set_paper_trail_whodunnit
|
||||
before_action :set_domain, only: %i[index update]
|
||||
before_action :verify_updateable, only: %i[index update]
|
||||
|
||||
def index
|
||||
render json: {
|
||||
domain_name: @domain.name,
|
||||
current_registrant: serialized_registrant(@domain.registrant),
|
||||
new_registrant: serialized_registrant(@domain.pending_registrant)
|
||||
}
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def serialized_registrant(registrant)
|
||||
{
|
||||
name: registrant.try(:name),
|
||||
ident: registrant.try(:ident),
|
||||
country: registrant.try(:ident_country_code)
|
||||
}
|
||||
end
|
||||
|
||||
def confirmation_params
|
||||
params do |p|
|
||||
p.require(:name)
|
||||
p.require(:token)
|
||||
end
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find_by(name: confirmation_params[:name])
|
||||
return if @domain
|
||||
|
||||
render json: { error: 'Domain not found' }, status: :not_found
|
||||
end
|
||||
|
||||
def verify_updateable
|
||||
return if @domain.registrant_update_confirmable?(confirmation_params[:token])
|
||||
|
||||
render json: { error: 'Application expired or not found' },
|
||||
status: :unauthorized
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -56,12 +56,12 @@ Rails.application.routes.draw do
|
|||
namespace :v1 do
|
||||
namespace :registrant do
|
||||
post 'auth/eid', to: 'auth#eid'
|
||||
|
||||
get 'confirms/:name/:token', to: 'confirms#index', constraints: { name: /[^\/]+/ }
|
||||
post 'confirms/:name/:token', to: 'confirms#update', constraints: { name: /[^\/]+/ }
|
||||
resources :domains, only: %i[index show], param: :uuid do
|
||||
resource :registry_lock, only: %i[create destroy]
|
||||
end
|
||||
resources :contacts, only: %i[index show update], param: :uuid
|
||||
resources :companies, only: %i[index]
|
||||
end
|
||||
|
||||
resources :auctions, only: %i[index show update], param: :uuid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue