mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 10:45:58 +02:00
Merge pull request #1859 from internetee/1826-remove-code-for-old-registrant-portal
Drop legacy registrant portal
This commit is contained in:
commit
efdecb6d3f
49 changed files with 2 additions and 1777 deletions
|
@ -1,115 +0,0 @@
|
|||
class Registrant::ContactsController < RegistrantController
|
||||
helper_method :domain
|
||||
helper_method :fax_enabled?
|
||||
helper_method :domain_filter_params
|
||||
skip_authorization_check only: %i[edit update]
|
||||
before_action :set_contact, only: [:show]
|
||||
|
||||
def show
|
||||
@requester_contact = Contact.find_by(ident: current_registrant_user.ident)
|
||||
authorize! :read, @contact
|
||||
end
|
||||
|
||||
def edit
|
||||
@contact = current_user_contacts.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@contact = current_user_contacts.find(params[:id])
|
||||
@contact.attributes = contact_params
|
||||
response = update_contact_via_api(@contact.uuid)
|
||||
updated = response.is_a?(Net::HTTPSuccess)
|
||||
|
||||
if updated
|
||||
redirect_to registrant_domain_contact_url(domain, @contact), notice: t('.updated')
|
||||
else
|
||||
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
||||
@errors = parsed_response[:errors]
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_contact
|
||||
id = params[:id]
|
||||
contact = domain.contacts.find_by(id: id) || current_user_contacts.find_by(id: id)
|
||||
contact ||= Contact.find_by(id: id, ident: domain.registrant.ident)
|
||||
@contact = contact
|
||||
end
|
||||
|
||||
def domain
|
||||
current_user_domains.find(params[:domain_id])
|
||||
end
|
||||
|
||||
def contact_params
|
||||
permitted = %i[
|
||||
name
|
||||
email
|
||||
phone
|
||||
]
|
||||
|
||||
permitted << :fax if fax_enabled?
|
||||
permitted += %i[street zip city state country_code] if Contact.address_processing?
|
||||
params.require(:contact).permit(*permitted)
|
||||
end
|
||||
|
||||
def access_token
|
||||
uri = URI.parse("#{ENV['registrant_api_base_url']}/api/v1/registrant/auth/eid")
|
||||
request = Net::HTTP::Post.new(uri)
|
||||
request.form_data = access_token_request_params
|
||||
|
||||
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
|
||||
http.request(request)
|
||||
end
|
||||
|
||||
json_doc = JSON.parse(response.body, symbolize_names: true)
|
||||
json_doc[:access_token]
|
||||
end
|
||||
|
||||
def access_token_request_params
|
||||
{ ident: current_registrant_user.ident,
|
||||
first_name: current_registrant_user.first_name,
|
||||
last_name: current_registrant_user.last_name }
|
||||
end
|
||||
|
||||
def fax_enabled?
|
||||
ENV['fax_enabled'] == 'true'
|
||||
end
|
||||
|
||||
def contact_update_api_params
|
||||
params = contact_params
|
||||
params = normalize_address_attributes_for_api(params) if Contact.address_processing?
|
||||
params
|
||||
end
|
||||
|
||||
def normalize_address_attributes_for_api(params)
|
||||
normalized = params
|
||||
address_parts = {}
|
||||
|
||||
Contact.address_attribute_names.each do |attr|
|
||||
attr = attr.to_sym
|
||||
address_parts[attr] = params[attr]
|
||||
normalized.delete(attr)
|
||||
end
|
||||
|
||||
normalized[:address] = address_parts
|
||||
normalized
|
||||
end
|
||||
|
||||
def update_contact_via_api(uuid)
|
||||
uri = URI.parse("#{ENV['registrant_api_base_url']}/api/v1/registrant/contacts/#{uuid}")
|
||||
request = Net::HTTP::Patch.new(uri)
|
||||
request['Authorization'] = "Bearer #{access_token}"
|
||||
request['Content-type'] = 'application/json'
|
||||
request.body = contact_update_api_params.to_json
|
||||
|
||||
Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
|
||||
http.request(request)
|
||||
end
|
||||
end
|
||||
|
||||
def domain_filter_params
|
||||
params.permit(:domain_filter)
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
class Registrant::DomainDeleteConfirmsController < RegistrantController
|
||||
skip_before_action :authenticate_registrant_user!, only: [:show, :update]
|
||||
skip_authorization_check only: [:show, :update]
|
||||
|
||||
def show
|
||||
return if params[:confirmed] || params[:rejected]
|
||||
|
||||
@domain = Domain.find(params[:id])
|
||||
@domain = nil unless @domain.registrant_delete_confirmable?(params[:token])
|
||||
end
|
||||
|
||||
def update
|
||||
@domain = Domain.find(params[:id])
|
||||
unless @domain.registrant_delete_confirmable?(params[:token])
|
||||
flash[:alert] = t(:registrant_domain_verification_failed)
|
||||
return render 'show'
|
||||
end
|
||||
|
||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||
verification_token: params[:token])
|
||||
|
||||
initiator = current_registrant_user ? current_registrant_user.username :
|
||||
t(:user_not_authenticated)
|
||||
|
||||
confirmed = params[:confirmed] ? true : false
|
||||
action = if confirmed
|
||||
@registrant_verification.domain_registrant_delete_confirm!("email link #{initiator}")
|
||||
else
|
||||
@registrant_verification.domain_registrant_delete_reject!("email link #{initiator}")
|
||||
end
|
||||
|
||||
fail_msg = t("registrant_domain_delete_#{confirmed ? 'confirmed' : 'rejected'}_failed".to_sym)
|
||||
success_msg = t("registrant_domain_verification_#{confirmed ? 'confirmed' : 'rejected'}".to_sym)
|
||||
|
||||
flash[:alert] = action ? success_msg : fail_msg
|
||||
(render 'show' && return) unless action
|
||||
|
||||
if confirmed
|
||||
redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true)
|
||||
else
|
||||
redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
class Registrant::DomainUpdateConfirmsController < RegistrantController
|
||||
skip_before_action :authenticate_registrant_user!, only: %i[show update]
|
||||
skip_authorization_check only: %i[show update]
|
||||
|
||||
def show
|
||||
return if params[:confirmed] || params[:rejected]
|
||||
@domain = Domain.find(params[:id])
|
||||
@domain = nil unless @domain.registrant_update_confirmable?(params[:token])
|
||||
end
|
||||
|
||||
def update
|
||||
@domain = Domain.find(params[:id])
|
||||
unless @domain.registrant_update_confirmable?(params[:token])
|
||||
flash[:alert] = t(:registrant_domain_verification_failed)
|
||||
return render 'show'
|
||||
end
|
||||
|
||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||
verification_token: params[:token])
|
||||
|
||||
initiator = current_registrant_user ? current_registrant_user.username :
|
||||
t(:user_not_authenticated)
|
||||
|
||||
if params[:rejected]
|
||||
if @registrant_verification.domain_registrant_change_reject!("email link, #{initiator}")
|
||||
flash[:notice] = t(:registrant_domain_verification_rejected)
|
||||
redirect_to registrant_domain_update_confirm_path(@domain.id, rejected: true)
|
||||
else
|
||||
flash[:alert] = t(:registrant_domain_verification_rejected_failed)
|
||||
return render 'show'
|
||||
end
|
||||
elsif params[:confirmed]
|
||||
if @registrant_verification.domain_registrant_change_confirm!("email link, #{initiator}")
|
||||
Dispute.close_by_domain(@domain.name) if @domain.disputed?
|
||||
|
||||
flash[:notice] = t(:registrant_domain_verification_confirmed)
|
||||
redirect_to registrant_domain_update_confirm_path(@domain.id, confirmed: true)
|
||||
else
|
||||
flash[:alert] = t(:registrant_domain_verification_confirmed_failed)
|
||||
return render 'show'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,79 +0,0 @@
|
|||
class Registrant::DomainsController < RegistrantController
|
||||
def index
|
||||
authorize! :view, :registrant_domains
|
||||
|
||||
params[:q] ||= {}
|
||||
normalize_search_parameters do
|
||||
@q = current_user_domains.search(search_params)
|
||||
end
|
||||
|
||||
domains = @q.result
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
@domains = domains.page(params[:page])
|
||||
domains_per_page = params[:results_per_page].to_i
|
||||
@domains = @domains.per(domains_per_page) if domains_per_page.positive?
|
||||
end
|
||||
format.csv do
|
||||
raw_csv = @q.result.to_csv
|
||||
send_data raw_csv, filename: 'domains.csv', type: "#{Mime[:csv]}; charset=utf-8"
|
||||
end
|
||||
format.pdf do
|
||||
view = ActionView::Base.new(ActionController::Base.view_paths, domains: domains)
|
||||
raw_html = view.render(file: 'registrant/domains/list_pdf', layout: false)
|
||||
raw_pdf = domains.pdf(raw_html)
|
||||
|
||||
send_data raw_pdf, filename: 'domains.pdf'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@domain = current_user_domains.find(params[:id])
|
||||
authorize! :read, @domain
|
||||
end
|
||||
|
||||
def confirmation
|
||||
authorize! :view, :registrant_domains
|
||||
domain = current_user_domains.find(params[:id])
|
||||
|
||||
if (domain.statuses.include?(DomainStatus::PENDING_UPDATE) ||
|
||||
domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
|
||||
domain.pending_json.present?
|
||||
|
||||
@domain = domain
|
||||
@confirmation_url = confirmation_url(domain)
|
||||
else
|
||||
flash[:warning] = I18n.t('available_verification_url_not_found')
|
||||
redirect_to registrant_domain_path(domain)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def normalize_search_parameters
|
||||
ca_cache = params[:q][:valid_to_lteq]
|
||||
begin
|
||||
end_time = params[:q][:valid_to_lteq].try(:to_date)
|
||||
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
|
||||
rescue
|
||||
logger.warn('Invalid date')
|
||||
end
|
||||
yield
|
||||
params[:q][:valid_to_lteq] = ca_cache
|
||||
end
|
||||
|
||||
def confirmation_url(domain)
|
||||
if domain.statuses.include?(DomainStatus::PENDING_UPDATE)
|
||||
registrant_domain_update_confirm_url(token: domain.registrant_verification_token)
|
||||
elsif domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
registrant_domain_delete_confirm_url(token: domain.registrant_verification_token)
|
||||
end
|
||||
end
|
||||
|
||||
def search_params
|
||||
params.require(:q).permit(:name_matches, :registrant_ident_eq, :valid_to_gteq, :valid_to_lteq,
|
||||
:results_per_page)
|
||||
end
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
class Registrant::RegistrarsController < RegistrantController
|
||||
def show
|
||||
@registrar = Registrar.find(params[:id])
|
||||
authorize! :read, @registrar
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
class Registrant::SessionsController < Devise::SessionsController
|
||||
layout 'registrant/application'
|
||||
|
||||
private
|
||||
|
||||
def after_sign_in_path_for(_resource_or_scope)
|
||||
registrant_root_path
|
||||
end
|
||||
|
||||
def after_sign_out_path_for(_resource_or_scope)
|
||||
new_registrant_user_session_path
|
||||
end
|
||||
|
||||
def user_for_paper_trail
|
||||
current_registrant_user.present? ? current_registrant_user.id_role_username : 'anonymous'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue