Commit 3afa696e089fec102bf7110c1808120c5566e6d5
1 parent
6a5c9a59
Exists in
master
and in
28 other branches
Don't crash for not logged users
(ActionItem1673)
Showing
2 changed files
with
19 additions
and
1 deletions
Show diff stats
app/controllers/public/profile_controller.rb
... | ... | @@ -3,7 +3,7 @@ class ProfileController < PublicController |
3 | 3 | needs_profile |
4 | 4 | before_filter :check_access_to_profile, :except => [:join, :join_not_logged, :index] |
5 | 5 | before_filter :store_before_join, :only => [:join, :join_not_logged] |
6 | - before_filter :login_required, :only => [:join, :join_not_logged, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_scraps, :view_more_activities, :view_more_network_activities] | |
6 | + before_filter :login_required, :only => [:add, :join, :join_not_logged, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_scraps, :view_more_activities, :view_more_network_activities] | |
7 | 7 | |
8 | 8 | helper TagsHelper |
9 | 9 | |
... | ... | @@ -121,6 +121,10 @@ class ProfileController < PublicController |
121 | 121 | end |
122 | 122 | |
123 | 123 | def check_membership |
124 | + unless logged_in? | |
125 | + render :text => '' | |
126 | + return | |
127 | + end | |
124 | 128 | if user.memberships.include?(profile) |
125 | 129 | render :text => 'true' |
126 | 130 | else |
... | ... | @@ -139,6 +143,10 @@ class ProfileController < PublicController |
139 | 143 | end |
140 | 144 | |
141 | 145 | def check_friendship |
146 | + unless logged_in? | |
147 | + render :text => '' | |
148 | + return | |
149 | + end | |
142 | 150 | if user == profile || user.already_request_friendship?(profile) || user.is_a_friend?(profile) |
143 | 151 | render :text => 'true' |
144 | 152 | else | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -1038,4 +1038,14 @@ class ProfileControllerTest < Test::Unit::TestCase |
1038 | 1038 | assert_redirected_to :controller => 'account', :action => 'login' |
1039 | 1039 | end |
1040 | 1040 | |
1041 | + should 'render empty response for not logged in users in check_membership' do | |
1042 | + get :check_membership | |
1043 | + assert_equal '', @response.body | |
1044 | + end | |
1045 | + | |
1046 | + should 'render empty response for not logged in users in check_friendship' do | |
1047 | + get :check_friendship | |
1048 | + assert_equal '', @response.body | |
1049 | + end | |
1050 | + | |
1041 | 1051 | end | ... | ... |