FIX: allow exisiting users to be invited to topic/message when enable_local_logins is disabled
This commit is contained in:
parent
6c6d406e63
commit
9f8d6b6088
|
@ -68,12 +68,12 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
|
||||
// Show Groups? (add invited user to private group)
|
||||
showGroups: function() {
|
||||
return this.get('isAdmin') && (Discourse.Utilities.emailValid(this.get('emailOrUsername')) || this.get('isPrivateTopic') || !this.get('invitingToTopic')) && !Discourse.SiteSettings.enable_sso && !this.get('isMessage');
|
||||
return this.get('isAdmin') && (Discourse.Utilities.emailValid(this.get('emailOrUsername')) || this.get('isPrivateTopic') || !this.get('invitingToTopic')) && !Discourse.SiteSettings.enable_sso && Discourse.SiteSettings.enable_local_logins && !this.get('isMessage');
|
||||
}.property('isAdmin', 'emailOrUsername', 'isPrivateTopic', 'isMessage', 'invitingToTopic'),
|
||||
|
||||
// Instructional text for the modal.
|
||||
inviteInstructions: function() {
|
||||
if (Discourse.SiteSettings.enable_sso) {
|
||||
if (Discourse.SiteSettings.enable_sso || !Discourse.SiteSettings.enable_local_logins) {
|
||||
// inviting existing user when SSO enabled
|
||||
return I18n.t('topic.invite_reply.sso_enabled');
|
||||
} else if (this.get('isMessage')) {
|
||||
|
@ -128,7 +128,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
}.property('isMessage'),
|
||||
|
||||
placeholderKey: function() {
|
||||
return Discourse.SiteSettings.enable_sso ?
|
||||
return (Discourse.SiteSettings.enable_sso || !Discourse.SiteSettings.enable_local_logins) ?
|
||||
'topic.invite_reply.username_placeholder' :
|
||||
'topic.invite_private.email_or_username_placeholder';
|
||||
}.property(),
|
||||
|
|
|
@ -585,7 +585,7 @@ class Topic < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
if username_or_email =~ /^.+@.+$/ && !SiteSetting.enable_sso
|
||||
if username_or_email =~ /^.+@.+$/ && !SiteSetting.enable_sso && SiteSetting.enable_local_logins
|
||||
# rate limit topic invite
|
||||
RateLimiter.new(invited_by, "topic-invitations-per-day", SiteSetting.max_topic_invitations_per_day, 1.day.to_i).performed!
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ class Guardian
|
|||
|
||||
def can_invite_to?(object, group_ids=nil)
|
||||
return false if ! authenticated?
|
||||
return false unless ( SiteSetting.enable_local_logins && (!SiteSetting.must_approve_users? || is_staff?) )
|
||||
return false unless (!SiteSetting.must_approve_users? || is_staff?)
|
||||
return true if is_admin?
|
||||
return false if (SiteSetting.max_invites_per_day.to_i == 0 && !is_staff?)
|
||||
return false if ! can_see?(object)
|
||||
|
|
|
@ -316,12 +316,6 @@ describe Guardian do
|
|||
expect(Guardian.new(coding_horror).can_invite_to?(topic)).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns false when local logins are disabled' do
|
||||
SiteSetting.stubs(:enable_local_logins).returns(false)
|
||||
expect(Guardian.new(moderator).can_invite_to?(topic)).to be_falsey
|
||||
expect(Guardian.new(user).can_invite_to?(topic)).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns false for normal user on private topic' do
|
||||
expect(Guardian.new(user).can_invite_to?(private_topic)).to be_falsey
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue