-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into improve-epp-poll-tests
- Loading branch information
Showing
37 changed files
with
763 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ exclude_patterns: | |
- "vendor/" | ||
- "test/" | ||
- "spec/" | ||
- "CHANGELOG.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Admin | ||
module Domains | ||
class RegistryLockController < BaseController | ||
def destroy | ||
set_domain | ||
authorize! :manage, @domain | ||
if @domain.remove_registry_lock | ||
redirect_to edit_admin_domain_url(@domain), notice: t('.success') | ||
else | ||
redirect_to edit_admin_domain_url(@domain), alert: t('.error') | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_domain | ||
@domain = Domain.find(params[:domain_id]) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/controllers/api/v1/registrant/registry_locks_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Api | ||
module V1 | ||
module Registrant | ||
class RegistryLocksController < BaseController | ||
before_action :set_domain | ||
before_action :authorized_to_manage_locks? | ||
|
||
def create | ||
if @domain.apply_registry_lock | ||
render json: @domain | ||
else | ||
render json: { errors: [{ base: ['Domain cannot be locked'] }] }, | ||
status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
if @domain.remove_registry_lock | ||
render json: @domain | ||
else | ||
render json: { errors: [{ base: ['Domain is not locked'] }] }, | ||
status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_domain | ||
domain_pool = current_registrant_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_registrant_user.administered_domains.include?(@domain) | ||
|
||
render json: { errors: [ | ||
{ base: ['Only administrative contacts can manage registry locks'] } | ||
] }, | ||
status: :unauthorized and return | ||
end | ||
end | ||
end | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
app/controllers/registrant/domain_delete_confirms_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/controllers/registrant/domain_update_confirms_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module Concerns | ||
module Domain | ||
module RegistryLockable | ||
extend ActiveSupport::Concern | ||
|
||
def apply_registry_lock | ||
return unless registry_lockable? | ||
return if locked_by_registrant? | ||
|
||
transaction do | ||
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED | ||
statuses << DomainStatus::SERVER_DELETE_PROHIBITED | ||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED | ||
self.locked_by_registrant_at = Time.zone.now | ||
|
||
save! | ||
end | ||
end | ||
|
||
def registry_lockable? | ||
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION, | ||
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE, | ||
DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW, | ||
DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE]).empty? | ||
end | ||
|
||
def locked_by_registrant? | ||
return false unless locked_by_registrant_at | ||
|
||
lock_statuses = [DomainStatus::SERVER_UPDATE_PROHIBITED, | ||
DomainStatus::SERVER_DELETE_PROHIBITED, | ||
DomainStatus::SERVER_TRANSFER_PROHIBITED] | ||
|
||
(statuses & lock_statuses).count == 3 | ||
end | ||
|
||
def remove_registry_lock | ||
return unless locked_by_registrant? | ||
|
||
transaction do | ||
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED) | ||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED) | ||
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED) | ||
self.locked_by_registrant_at = nil | ||
|
||
save! | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.