mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
Revert "Merge pull request #2116 from LessonPlanet/disable-name-edit-for-sso"
This reverts commit 91aa21671ac67300a083d512c42a130e6b5123da, reversing changes made to f19596af0ddfeabf463fdf69f66755dc776d4c65.
This commit is contained in:
@ -25,11 +25,7 @@
|
|||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{i18n user.name.title}}</label>
|
<label class="control-label">{{i18n user.name.title}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{#if can_edit_name}}
|
{{textField value=newNameInput classNames="input-xxlarge"}}
|
||||||
{{textField value=newNameInput classNames="input-xxlarge"}}
|
|
||||||
{{else}}
|
|
||||||
<span class='static'>{{name}}</span>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class='instructions'>
|
<div class='instructions'>
|
||||||
{{i18n user.name.instructions}}
|
{{i18n user.name.instructions}}
|
||||||
@ -77,7 +73,7 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if Discourse.SiteSettings.allow_profile_backgrounds}}
|
{{#if Discourse.SiteSettings.allow_profile_backgrounds}}
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{i18n user.change_profile_background.title}}</label>
|
<label class="control-label">{{i18n user.change_profile_background.title}}</label>
|
||||||
|
@ -19,13 +19,6 @@ module UserGuardian
|
|||||||
can_edit?(user)
|
can_edit?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_edit_name?(user)
|
|
||||||
return false if not(SiteSetting.enable_names?)
|
|
||||||
return false if (SiteSetting.sso_overrides_name? && SiteSetting.enable_sso?)
|
|
||||||
return true if is_staff?
|
|
||||||
can_edit?(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def can_block_user?(user)
|
def can_block_user?(user)
|
||||||
user && is_staff? && not(user.staff?)
|
user && is_staff? && not(user.staff?)
|
||||||
end
|
end
|
||||||
@ -44,4 +37,4 @@ module UserGuardian
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -1487,68 +1487,5 @@ describe Guardian do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'can_edit_name?' do
|
|
||||||
it 'is false without a logged in user' do
|
|
||||||
Guardian.new(nil).can_edit_name?(build(:user, created_at: 1.minute.ago)).should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
it "is false for regular users to edit another user's name" do
|
|
||||||
Guardian.new(build(:user)).can_edit_name?(build(:user, created_at: 1.minute.ago)).should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'for a new user' do
|
|
||||||
let(:target_user) { build(:user, created_at: 1.minute.ago) }
|
|
||||||
|
|
||||||
it 'is true for the user to change their own name' do
|
|
||||||
Guardian.new(target_user).can_edit_name?(target_user).should be_true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is true for moderators' do
|
|
||||||
Guardian.new(moderator).can_edit_name?(user).should be_true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is true for admins' do
|
|
||||||
Guardian.new(admin).can_edit_name?(user).should be_true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when name is disabled in preferences' do
|
|
||||||
before do
|
|
||||||
SiteSetting.stubs(:enable_names).returns(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is false for the user to change their own name' do
|
|
||||||
Guardian.new(user).can_edit_name?(user).should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is false for moderators' do
|
|
||||||
Guardian.new(moderator).can_edit_name?(user).should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is false for admins' do
|
|
||||||
Guardian.new(admin).can_edit_name?(user).should be_false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when SSO name override is active' do
|
|
||||||
before do
|
|
||||||
SiteSetting.stubs(:enable_sso).returns(true)
|
|
||||||
SiteSetting.stubs(:sso_overrides_name).returns(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is false for admins' do
|
|
||||||
Guardian.new(admin).can_edit_name?(admin).should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is false for moderators' do
|
|
||||||
Guardian.new(moderator).can_edit_name?(moderator).should be_false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is false for users' do
|
|
||||||
Guardian.new(user).can_edit_name?(user).should be_false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user