mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 10:59:51 +08:00
FIX: redirect to login page for anonymous user when profiles are hidden
This commit is contained in:
parent
5c39c8f24b
commit
ea26c56631
|
@ -36,7 +36,7 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
raise Discourse::InvalidAccess if SiteSetting.hide_user_profiles_from_public && !current_user
|
return redirect_to path('/login') if SiteSetting.hide_user_profiles_from_public && !current_user
|
||||||
|
|
||||||
@user = fetch_user_from_params(
|
@user = fetch_user_from_params(
|
||||||
{ include_inactive: current_user.try(:staff?) },
|
{ include_inactive: current_user.try(:staff?) },
|
||||||
|
|
|
@ -13,10 +13,10 @@ describe UsersController do
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error for anon when profiles are hidden" do
|
it "should redirect to login page for anonymous user when profiles are hidden" do
|
||||||
SiteSetting.hide_user_profiles_from_public = true
|
SiteSetting.hide_user_profiles_from_public = true
|
||||||
xhr :get, :show, username: user.username, format: :json
|
xhr :get, :show, username: user.username, format: :json
|
||||||
expect(response).not_to be_success
|
expect(response).to redirect_to '/login'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user