mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
Make sure that only admin contacts and registrants can lock a domain
This commit is contained in:
parent
1d53e7bb5b
commit
a64b03d204
4 changed files with 49 additions and 14 deletions
|
@ -3,6 +3,7 @@ module Api
|
|||
module Registrant
|
||||
class RegistryLocksController < BaseController
|
||||
before_action :set_domain
|
||||
before_action :authorized_to_manage_locks?
|
||||
|
||||
def create
|
||||
if @domain.apply_registry_lock
|
||||
|
@ -25,13 +26,22 @@ module Api
|
|||
private
|
||||
|
||||
def set_domain
|
||||
domain_pool = current_user.administrated_domains
|
||||
domain_pool = current_user.domains
|
||||
@domain = domain_pool.find_by(uuid: params[:domain_uuid])
|
||||
|
||||
return if @domain
|
||||
render json: { errors: [{ base: ['Domain not found'] }] },
|
||||
status: :not_found and return
|
||||
end
|
||||
|
||||
def authorized_to_manage_locks?
|
||||
return if current_user.administrated_domains.include?(@domain)
|
||||
|
||||
render json: { errors: [
|
||||
{ base: ['Only administrative contacts can manage registry locks'] }
|
||||
] },
|
||||
status: :unauthorized and return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue