Commit e5ecf4b1e326d81e05fec75b7d30b9cad917d5e6

Authored by Rodrigo Souto
1 parent 55f802bd

api: treat not_founds on people

Showing 1 changed file with 3 additions and 0 deletions   Show diff stats
lib/noosfero/api/v1/people.rb
@@ -44,6 +44,7 @@ module Noosfero @@ -44,6 +44,7 @@ module Noosfero
44 desc "Return the person information" 44 desc "Return the person information"
45 get ':id' do 45 get ':id' do
46 person = environment.people.visible_for_person(current_person).find_by_id(params[:id]) 46 person = environment.people.visible_for_person(current_person).find_by_id(params[:id])
  47 + return not_found! if person.blank?
47 present person, :with => Entities::Person 48 present person, :with => Entities::Person
48 end 49 end
49 50
@@ -69,6 +70,7 @@ module Noosfero @@ -69,6 +70,7 @@ module Noosfero
69 desc "Return the person friends" 70 desc "Return the person friends"
70 get ':id/friends' do 71 get ':id/friends' do
71 person = environment.people.visible_for_person(current_person).find_by_id(params[:id]) 72 person = environment.people.visible_for_person(current_person).find_by_id(params[:id])
  73 + return not_found! if person.blank?
72 friends = person.friends.visible 74 friends = person.friends.visible
73 present friends, :with => Entities::Person 75 present friends, :with => Entities::Person
74 end 76 end
@@ -76,6 +78,7 @@ module Noosfero @@ -76,6 +78,7 @@ module Noosfero
76 desc "Return the person permissions on other profiles" 78 desc "Return the person permissions on other profiles"
77 get ":id/permissions" do 79 get ":id/permissions" do
78 person = environment.people.find(params[:id]) 80 person = environment.people.find(params[:id])
  81 + return not_found! if person.blank?
79 return forbidden! unless current_person == person || environment.admins.include?(current_person) 82 return forbidden! unless current_person == person || environment.admins.include?(current_person)
80 83
81 output = {} 84 output = {}