Find contact/registrar directly via domain or via relations

This commit is contained in:
Karl Erik Õunapuu 2020-05-15 13:27:33 +03:00
parent bd7b6ddb73
commit 572510d7b0
3 changed files with 18 additions and 8 deletions

View file

@ -3,9 +3,9 @@ class Registrant::ContactsController < RegistrantController
helper_method :fax_enabled?
helper_method :domain_filter_params
skip_authorization_check only: %i[edit update]
before_action :set_contact, only: [:show]
def show
@contact = domain.contacts.find(params[:id])
@requester_contact = Contact.find_by(ident: current_registrant_user.ident).id
authorize! :read, @contact
end
@ -31,6 +31,13 @@ class Registrant::ContactsController < RegistrantController
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