Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use radio group for self register

Oliver Güntherff89d259accd
diff --git a/app/forms/settings/form_decorator.rb b/app/forms/settings/form_decorator.rb
index 0192dfcecd9..cafe20c91e6 100644
--- a/app/forms/settings/form_decorator.rb
+++ b/app/forms/settings/form_decorator.rb
@@ -104,8 +104,10 @@ module Settings
# Any options passed to this method will override the default options.
#
# @param name [Symbol] The name of the setting
- # @param values [Array] The values for the radio buttons. Default to the
+ # @param values [Hash|Array] The values for the radio buttons. Default to the
# setting's allowed values.
+ # If a hash is provided, it is assumed it provides a :name (to derive the labels) and a :value key.
+ # Other keys are used as arguments to the radio_button.
# @param disabled [Boolean] Force the radio button group to be disabled when
# true, will be disabled if the setting is not writable when false (default)
# @param button_options [Hash] Options for individual radio buttons
@@ -122,15 +124,25 @@ module Settings
**radio_group_options
) do |radio_group|
values.each do |value|
- radio_group.radio_button(
- **button_options.reverse_merge(
- value:,
- checked: setting_value(name) == value,
- autocomplete: "off",
- label: setting_label(name, value),
- caption: setting_caption(name, value)
- )
- )
+ args =
+ if value.is_a?(Hash)
+ value.reverse_merge(
+ checked: setting_value(name) == value[:value],
+ autocomplete: "off",
+ label: setting_label(name, value[:name]),
+ caption: setting_caption(name, value[:name])
+ )
+ else
+ {
+ value:,
+ checked: setting_value(name) == value,
+ autocomplete: "off",
+ label: setting_label(name, value),
+ caption: setting_caption(name, value)
+ }
+ end
+
+ radio_group.radio_button(**button_options.reverse_merge(args))
end
end
end
diff --git a/app/views/admin/settings/authentication_settings/_registration.html.erb b/app/views/admin/settings/authentication_settings/_registration.html.erb
index 267dee4f2af..50c11d5588c 100644
--- a/app/views/admin/settings/authentication_settings/_registration.html.erb
+++ b/app/views/admin/settings/authentication_settings/_registration.html.erb
@@ -36,23 +36,14 @@ See COPYRIGHT and LICENSE files for more details.
form.check_box(
name: :login_required,
caption: I18n.t(:setting_login_required_caption),
- )
+ )
- form.select_list(
+ form.radio_button_group(
name: :self_registration,
- input_width: :medium,
label: I18n.t(:setting_self_registration),
- include_blank: false
- ) do |select|
- Setting::SelfRegistration::VALUES.each do |key, value|
- label = key == :disabled ? I18n.t(:label_disabled) : I18n.t("label_registration_#{key}")
- select.option(
- value:,
- label:,
- selected: Setting.self_registration == value
- )
- end
- end
+ caption: I18n.t(:setting_self_registration_caption),
+ values: Setting::SelfRegistration::VALUES.map { |name, value| { name:, value: } }
+ )
if Setting::SelfRegistration.unsupervised_registration?
form.html_content do
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 22b2e6d980f..8cd7517473d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2974,9 +2974,6 @@ en:
label_register: "Create a new account"
label_register_with_developer: "Register as developer"
label_registered_on: "Registered on"
- label_registration_activation_by_email: "account activation by email"
- label_registration_automatic_activation: "automatic account activation"
- label_registration_manual_activation: "manual account activation"
label_related_work_packages: "Related work packages"
label_relates: "related to"
label_relates_to: "related to"
@@ -3923,10 +3920,29 @@ en:
setting_repository_truncate_at: "Maximum number of files displayed in the repository browser"
setting_rest_api_enabled: "Enable REST web service"
setting_self_registration: "Self-registration"
+ setting_self_registration_caption: >
+ Choose the self-registration mechanism for users. Be careful with the setting you choose, as some
+ options allow users to activate their own accounts to this instance.
setting_self_registration_warning: >
The user will be able to activate their own accounts.
Please note that this will give them access to all public projects and their content.
Please make sure that no sensitive or private data is exposed in public projects.
+ setting_self_registration_disabled: "Disabled"
+ setting_self_registration_disabled_caption: >
+ No accounts can be registered on their own. Only administrators and users with the global permission
+ to create new users are able to create new accounts.
+ setting_self_registration_activation_by_email: "Account activation by email"
+ setting_self_registration_activation_by_email_caption: >
+ Users can register on their own and activate their account after confirming their email address.
+ Administrators have no moderation control over the activation process.
+ setting_self_registration_automatic_activation: "Automatic account activation"
+ setting_self_registration_automatic_activation_caption: >
+ Users can register on their own. Their accounts are immediately active without further action.
+ Administrators have no moderation control over the activation process.
+ setting_self_registration_manual_activation: "Manual account activation"
+ setting_self_registration_manual_activation_caption: >
+ Users can register on their own. Their accounts are in a pending state until an administrator
+ or user with the global permission to create or manage users activates them.
setting_session_ttl: "Session expiry time after inactivity"
setting_session_ttl_hint: "Value below 5 works like disabled"
setting_session_ttl_enabled: "Session expires"