diff --git a/app/serializers/wizard_step_serializer.rb b/app/serializers/wizard_step_serializer.rb
index 0f9bccd4fa1..458bee2c853 100644
--- a/app/serializers/wizard_step_serializer.rb
+++ b/app/serializers/wizard_step_serializer.rb
@@ -39,6 +39,8 @@ class WizardStepSerializer < ApplicationSerializer
end
def description
+ return translate("disabled") if object.disabled
+
translate("description", base_path: Discourse.base_path)
end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 80db8ed306d..7613a3861a5 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -4112,6 +4112,7 @@ en:
invites:
title: "Invite Staff"
description: "You’re almost done! Let’s invite some people to help seed your discussions with interesting topics and replies to get your community started."
+ disabled: "Since local logins are disabled, it’s not possible to send invites to anyone. Please proceed to the next step."
finished:
title: "Your Discourse is Ready!"
diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb
index 18d198f50c1..fd46229086a 100644
--- a/lib/wizard/builder.rb
+++ b/lib/wizard/builder.rb
@@ -233,24 +233,27 @@ class Wizard
end
@wizard.append_step('invites') do |step|
+ if SiteSetting.enable_local_logins
+ staff_count = User.staff.human_users.where('username_lower not in (?)', reserved_usernames).count
+ step.add_field(id: 'staff_count', type: 'component', value: staff_count)
- staff_count = User.staff.human_users.where('username_lower not in (?)', reserved_usernames).count
- step.add_field(id: 'staff_count', type: 'component', value: staff_count)
+ step.add_field(id: 'invite_list', type: 'component')
- step.add_field(id: 'invite_list', type: 'component')
+ step.on_update do |updater|
+ users = JSON.parse(updater.fields[:invite_list])
- step.on_update do |updater|
- users = JSON.parse(updater.fields[:invite_list])
-
- users.each do |u|
- args = {}
- args[:moderator] = true if u['role'] == 'moderator'
- begin
- Invite.create_invite_by_email(u['email'], @wizard.user, args)
- rescue => e
- updater.errors.add(:invite_list, e.message.concat("
"))
+ users.each do |u|
+ args = {}
+ args[:moderator] = true if u['role'] == 'moderator'
+ begin
+ Invite.create_invite_by_email(u['email'], @wizard.user, args)
+ rescue => e
+ updater.errors.add(:invite_list, e.message.concat("
"))
+ end
end
end
+ else
+ step.disabled = true
end
end
diff --git a/lib/wizard/step.rb b/lib/wizard/step.rb
index 40a8b9f6e5d..f059bd4e264 100644
--- a/lib/wizard/step.rb
+++ b/lib/wizard/step.rb
@@ -1,7 +1,7 @@
class Wizard
class Step
attr_reader :id, :updater
- attr_accessor :index, :fields, :next, :previous, :banner
+ attr_accessor :index, :fields, :next, :previous, :banner, :disabled
def initialize(id)
@id = id
diff --git a/spec/components/wizard/wizard_builder_spec.rb b/spec/components/wizard/wizard_builder_spec.rb
index 53052fbf674..25f4d7aa6a6 100644
--- a/spec/components/wizard/wizard_builder_spec.rb
+++ b/spec/components/wizard/wizard_builder_spec.rb
@@ -27,4 +27,14 @@ describe Wizard::Builder do
expect(wizard.steps).to be_blank
end
+ it "returns wizard with disabled invites step when local_logins are off" do
+ SiteSetting.enable_local_logins = false
+
+ wizard = Wizard::Builder.new(moderator).build
+
+ invites_step = wizard.steps.find { |s| s.id == "invites" }
+ expect(invites_step.fields).to be_blank
+ expect(invites_step.disabled).to be_truthy
+ end
+
end