Merge pull request #1527 from internetee/fix-registrant-contact-view

Registrant: Allow to view other contacts of domain
This commit is contained in:
Timo Võhmar 2020-05-21 14:31:12 +03:00 committed by GitHub
commit 3d30469db9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 28 deletions

View file

@ -3,9 +3,10 @@ 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 = current_user_contacts.find(params[:id])
@requester_contact = Contact.find_by(ident: current_registrant_user.ident).id
authorize! :read, @contact
end
@ -30,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