Skip to content

Commit

Permalink
Allow user to access their own DOB (#10618)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxidragon authored Jan 21, 2025
1 parent 1fa4218 commit 9ace921
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/controllers/api/v0/persons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ def index
end

def show
person = Person.current.includes(:user, :ranksSingle, :ranksAverage).find_by_wca_id!(params[:wca_id])
wca_id = params[:wca_id]
person = Person.current.includes(:user, :ranksSingle, :ranksAverage).find_by_wca_id!(wca_id)
private_attributes = []
if current_user && current_user.can_admin_results?
private_attributes = %w[incorrect_wca_id_claim_count dob]
if current_user
if current_user.wca_id == wca_id || current_user.any_kind_of_delegate?
private_attributes = %w[dob]
elsif current_user.can_admin_results?
private_attributes = %w[incorrect_wca_id_claim_count dob]
end
end
render json: person_to_json(person, private_attributes)
end
Expand Down

0 comments on commit 9ace921

Please sign in to comment.