mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Remove /client
This commit is contained in:
parent
cf11f1aaf8
commit
5754bbe297
42 changed files with 6 additions and 1155 deletions
|
@ -9,13 +9,8 @@ class ApplicationController < ActionController::Base
|
|||
params[resource] &&= send(method) if respond_to?(method, true)
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
def after_sign_in_path_for(_resource)
|
||||
return session[:user_return_to].to_s if session[:user_return_to]
|
||||
|
||||
if resource.admin? && can?(:create, :admin_session)
|
||||
admin_root_path
|
||||
else
|
||||
client_root_path
|
||||
end
|
||||
admin_root_path
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
class Client::ContactVersionsController < ClientController
|
||||
before_action :set_version, only: [:show]
|
||||
|
||||
def index
|
||||
@versions = ContactVersion.registrar_events(current_registrar.id)
|
||||
@versions.flatten!
|
||||
end
|
||||
|
||||
def show
|
||||
@event = params[:event]
|
||||
@contact = @version.reify(has_one: true) unless @event == 'create'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_version
|
||||
@version = ContactVersion.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -1,71 +0,0 @@
|
|||
class Client::ContactsController < ClientController
|
||||
before_action :set_contact, only: [:show, :destroy, :edit, :update]
|
||||
|
||||
def index
|
||||
@q = Contact.current_registrars(current_registrar.id).search(params[:q])
|
||||
@contacts = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@contact = Contact.new
|
||||
@contact.build_address
|
||||
end
|
||||
|
||||
def show
|
||||
# rubocop: disable Style/GuardClause
|
||||
if @contact.registrar != current_registrar
|
||||
flash[:alert] = I18n.t('shared.authentication_error')
|
||||
redirect_to client_contacts_path
|
||||
end
|
||||
# rubocop: enable Style/GuardClause
|
||||
end
|
||||
|
||||
def create
|
||||
@contact = Contact.new(contact_params)
|
||||
@contact.generate_code
|
||||
@contact.registrar = current_registrar
|
||||
if @contact.save
|
||||
flash[:notice] = I18n.t('shared.contact_added')
|
||||
redirect_to [:client, @contact]
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_create_contact')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @contact.destroy_and_clean
|
||||
flash[:notice] = I18n.t('shared.contact_deleted')
|
||||
redirect_to client_contacts_path
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_delete_contact')
|
||||
redirect_to [:client, @contact]
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @contact.update_attributes(contact_params)
|
||||
flash[:notice] = I18n.t('shared.contact_updated')
|
||||
redirect_to [:client, @contact]
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_update_contact')
|
||||
redirect_to [:client, @contact]
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Add Registrar to Contacts and search only contacts that belong to this domain
|
||||
def search
|
||||
render json: Contact.search_by_query(params[:q])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_contact
|
||||
@contact = Contact.find(params[:id])
|
||||
end
|
||||
|
||||
def contact_params
|
||||
params.require(:contact).permit(:email, :phone, :fax, :ident_type, :ident, :auth_info, :name, :org_name,
|
||||
address_attributes: [:city, :street, :zip, :street2, :street3, :country_id])
|
||||
end
|
||||
end
|
|
@ -1,92 +0,0 @@
|
|||
class Client::DomainTransfersController < ClientController
|
||||
before_action :set_domain_transfer, only: [:show, :approve]
|
||||
before_action :set_domain, only: [:create]
|
||||
|
||||
def index
|
||||
@q = current_registrar.domain_transfers.search(params[:q])
|
||||
@q.sorts = 'created_at desc' if @q.sorts.empty?
|
||||
@domain_transfers = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@domain_transfer = DomainTransfer.new
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def create
|
||||
@domain_transfer = @domain.pending_transfer
|
||||
|
||||
if @domain_transfer
|
||||
if can? :read, @domain_transfer
|
||||
flash[:notice] = I18n.t('shared.domain_transfer_requested') if @domain.registrar != current_registrar
|
||||
redirect_to [:client, @domain_transfer] and return
|
||||
else
|
||||
flash.now[:alert] = I18n.t('shared.other_registrar_has_already_requested_to_transfer_this_domain')
|
||||
render 'new' and return
|
||||
end
|
||||
end
|
||||
|
||||
@domain_transfer = @domain.domain_transfers.create(domain_transfer_params)
|
||||
@domain_transfer.approve_as_server if Setting.transfer_wait_time == 0
|
||||
|
||||
if @domain_transfer.approved?
|
||||
flash[:notice] = I18n.t('shared.domain_transfer_approved')
|
||||
redirect_to [:client, @domain_transfer]
|
||||
else
|
||||
flash[:notice] = I18n.t('shared.domain_transfer_requested')
|
||||
redirect_to [:client, @domain_transfer]
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def approve
|
||||
if can? :approve_as_client, @domain_transfer
|
||||
@domain_transfer.approve_as_client
|
||||
flash[:notice] = I18n.t('shared.domain_transfer_approved')
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_approve_domain_transfer')
|
||||
end
|
||||
|
||||
redirect_to [:client, @domain_transfer]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain_transfer
|
||||
@domain_transfer = DomainTransfer.find(params[:id])
|
||||
end
|
||||
|
||||
def domain_transfer_params
|
||||
{
|
||||
status: DomainTransfer::PENDING,
|
||||
transfer_requested_at: Time.zone.now,
|
||||
transfer_to: current_registrar,
|
||||
transfer_from: @domain.registrar
|
||||
}
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def set_domain
|
||||
@domain_transfer = DomainTransfer.new
|
||||
@domain = Domain.find_by(name: params[:domain_name])
|
||||
if @domain
|
||||
if @domain.auth_info != params[:domain_pw]
|
||||
flash.now[:alert] = I18n.t('shared.password_invalid')
|
||||
render 'new' and return
|
||||
end
|
||||
|
||||
if @domain.registrar == current_registrar && !@domain.pending_transfer
|
||||
flash.now[:alert] = I18n.t('shared.domain_already_belongs_to_the_querying_registrar')
|
||||
render 'new' and return
|
||||
end
|
||||
else
|
||||
flash.now[:alert] = I18n.t('shared.domain_was_not_found')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
# rubocop: enbale Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
class Client::DomainVersionsController < ClientController
|
||||
helper WhodunnitHelper
|
||||
before_action :set_domain, only: [:show]
|
||||
|
||||
def index
|
||||
@versions = DomainVersion.registrar_events(current_registrar.id)
|
||||
@versions.flatten!
|
||||
end
|
||||
|
||||
def show
|
||||
@versions = @domain.versions.reverse
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -1,105 +0,0 @@
|
|||
class Client::DomainsController < ClientController
|
||||
load_and_authorize_resource
|
||||
before_action :set_domain, only: [:show, :edit, :update, :destroy]
|
||||
before_action :verify_deletion, only: [:destroy]
|
||||
|
||||
def index
|
||||
@q = current_registrar.domains.includes(:owner_contact).search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
owner_contact = Contact.find(params[:owner_contact_id]) if params[:owner_contact_id]
|
||||
@domain = Domain.new(owner_contact: owner_contact, registrar: current_registrar)
|
||||
params[:domain_owner_contact] = owner_contact
|
||||
|
||||
build_associations
|
||||
end
|
||||
|
||||
def create
|
||||
add_prefix_to_statuses
|
||||
|
||||
@domain = Domain.new(domain_params)
|
||||
@domain.registrar = current_registrar
|
||||
|
||||
if @domain.save
|
||||
flash[:notice] = I18n.t('shared.domain_added')
|
||||
redirect_to [:client, @domain]
|
||||
else
|
||||
build_associations
|
||||
flash.now[:alert] = I18n.t('shared.failed_to_add_domain')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@domain.all_dependencies_valid?
|
||||
end
|
||||
|
||||
def edit
|
||||
build_associations
|
||||
end
|
||||
|
||||
def update
|
||||
add_prefix_to_statuses
|
||||
if @domain.update(domain_params)
|
||||
flash[:notice] = I18n.t('shared.domain_updated')
|
||||
redirect_to [:client, @domain]
|
||||
else
|
||||
build_associations
|
||||
flash.now[:alert] = I18n.t('shared.failed_to_update_domain')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @domain.destroy
|
||||
flash[:notice] = I18n.t('shared.domain_deleted')
|
||||
redirect_to client_domains_path
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_delete_domain')
|
||||
redirect_to [:client, @domain]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def domain_params
|
||||
params.require(:domain).permit(
|
||||
:name,
|
||||
:period,
|
||||
:period_unit,
|
||||
:owner_contact_id,
|
||||
:owner_contact_typeahead,
|
||||
nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy],
|
||||
domain_contacts_attributes: [:id, :contact_type, :contact_id, :value_typeahead, :_destroy],
|
||||
domain_statuses_attributes: [:id, :value, :description, :_destroy],
|
||||
dnskeys_attributes: [:id, :flags, :alg, :protocol, :public_key, :_destroy]
|
||||
)
|
||||
end
|
||||
|
||||
def add_prefix_to_statuses
|
||||
domain_params[:domain_statuses_attributes].each do |_k, hash|
|
||||
hash[:value] = hash[:value].prepend('client') if hash[:value].present?
|
||||
end
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
|
||||
def build_associations
|
||||
@domain.nameservers.build if @domain.nameservers.empty?
|
||||
@domain.dnskeys.build if @domain.dnskeys.empty?
|
||||
@domain.domain_contacts.build if @domain.domain_contacts.empty?
|
||||
|
||||
@client_statuses = @domain.domain_statuses.select(&:client_status?)
|
||||
@client_statuses << @domain.domain_statuses.build if @client_statuses.empty?
|
||||
end
|
||||
|
||||
def verify_deletion
|
||||
return if @domain.can_be_deleted?
|
||||
flash[:alert] = I18n.t('shared.domain_status_prohibits_deleting')
|
||||
redirect_to [:client, @domain]
|
||||
end
|
||||
end
|
|
@ -4,8 +4,6 @@ class SessionsController < Devise::SessionsController
|
|||
# this is just testing config
|
||||
# if Rails.env.development? || Rails.env.test?
|
||||
@user = User.find_by(username: 'gitlab') if params[:gitlab]
|
||||
@user = User.find_by(username: 'zone') if params[:zone]
|
||||
@user = User.find_by(username: 'elkdata') if params[:elkdata]
|
||||
|
||||
session[:current_user_registrar_id] = Registrar.first.id if @user.admin?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue