mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Don't allow invites if local logins are disabled, since it provides a way to bypass external auth
This commit is contained in:
parent
49efd30dfa
commit
4f523ae1b9
@ -191,6 +191,7 @@ class Guardian
|
|||||||
def can_invite_to_forum?(groups=nil)
|
def can_invite_to_forum?(groups=nil)
|
||||||
authenticated? &&
|
authenticated? &&
|
||||||
!SiteSetting.enable_sso &&
|
!SiteSetting.enable_sso &&
|
||||||
|
SiteSetting.enable_local_logins &&
|
||||||
(
|
(
|
||||||
(!SiteSetting.must_approve_users? && @user.has_trust_level?(:regular)) ||
|
(!SiteSetting.must_approve_users? && @user.has_trust_level?(:regular)) ||
|
||||||
is_staff?
|
is_staff?
|
||||||
|
@ -232,6 +232,12 @@ describe Guardian do
|
|||||||
Guardian.new(user).can_invite_to_forum?.should be_false
|
Guardian.new(user).can_invite_to_forum?.should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns false when the local logins are disabled' do
|
||||||
|
SiteSetting.stubs(:enable_local_logins).returns(false)
|
||||||
|
Guardian.new(user).can_invite_to_forum?.should be_false
|
||||||
|
Guardian.new(moderator).can_invite_to_forum?.should be_false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'can_invite_to?' do
|
describe 'can_invite_to?' do
|
||||||
@ -256,6 +262,12 @@ describe Guardian do
|
|||||||
Guardian.new(coding_horror).can_invite_to?(topic).should be_false
|
Guardian.new(coding_horror).can_invite_to?(topic).should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns false when local logins are disabled' do
|
||||||
|
SiteSetting.stubs(:enable_local_logins).returns(false)
|
||||||
|
Guardian.new(moderator).can_invite_to?(topic).should be_false
|
||||||
|
Guardian.new(user).can_invite_to?(topic).should be_false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'can_see?' do
|
describe 'can_see?' do
|
||||||
|
Loading…
Reference in New Issue
Block a user