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)
|
// Show Groups? (add invited user to private group)
|
||||||
showGroups: function() {
|
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'),
|
}.property('isAdmin', 'emailOrUsername', 'isPrivateTopic', 'isMessage', 'invitingToTopic'),
|
||||||
|
|
||||||
// Instructional text for the modal.
|
// Instructional text for the modal.
|
||||||
inviteInstructions: function() {
|
inviteInstructions: function() {
|
||||||
if (Discourse.SiteSettings.enable_sso) {
|
if (Discourse.SiteSettings.enable_sso || !Discourse.SiteSettings.enable_local_logins) {
|
||||||
// inviting existing user when SSO enabled
|
// inviting existing user when SSO enabled
|
||||||
return I18n.t('topic.invite_reply.sso_enabled');
|
return I18n.t('topic.invite_reply.sso_enabled');
|
||||||
} else if (this.get('isMessage')) {
|
} else if (this.get('isMessage')) {
|
||||||
|
@ -128,7 +128,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
}.property('isMessage'),
|
}.property('isMessage'),
|
||||||
|
|
||||||
placeholderKey: function() {
|
placeholderKey: function() {
|
||||||
return Discourse.SiteSettings.enable_sso ?
|
return (Discourse.SiteSettings.enable_sso || !Discourse.SiteSettings.enable_local_logins) ?
|
||||||
'topic.invite_reply.username_placeholder' :
|
'topic.invite_reply.username_placeholder' :
|
||||||
'topic.invite_private.email_or_username_placeholder';
|
'topic.invite_private.email_or_username_placeholder';
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
|
@ -585,7 +585,7 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if username_or_email =~ /^.+@.+$/ && !SiteSetting.enable_sso
|
if username_or_email =~ /^.+@.+$/ && !SiteSetting.enable_sso && SiteSetting.enable_local_logins
|
||||||
# rate limit topic invite
|
# rate limit topic invite
|
||||||
RateLimiter.new(invited_by, "topic-invitations-per-day", SiteSetting.max_topic_invitations_per_day, 1.day.to_i).performed!
|
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)
|
def can_invite_to?(object, group_ids=nil)
|
||||||
return false if ! authenticated?
|
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 true if is_admin?
|
||||||
return false if (SiteSetting.max_invites_per_day.to_i == 0 && !is_staff?)
|
return false if (SiteSetting.max_invites_per_day.to_i == 0 && !is_staff?)
|
||||||
return false if ! can_see?(object)
|
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
|
expect(Guardian.new(coding_horror).can_invite_to?(topic)).to be_falsey
|
||||||
end
|
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
|
it 'returns false for normal user on private topic' do
|
||||||
expect(Guardian.new(user).can_invite_to?(private_topic)).to be_falsey
|
expect(Guardian.new(user).can_invite_to?(private_topic)).to be_falsey
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue