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

[#41851] Blank Email reminders page when creating account manually

Dmitriifbeb65c1edca
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index 87f48cee4f8..a018534a3b9 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -300,20 +300,15 @@ class AccountController < ApplicationController
session[:auth_source_registration] = nil
if @user.nil?
- @user = User.new(language: Setting.default_language)
+ @user = assign_user_attributes({ language: Setting.default_language })
elsif user_with_placeholder_name?(@user)
- # force user to give their name
@user.firstname = nil
@user.lastname = nil
end
end
def self_registration!
- if @user.nil?
- @user = User.new
- @user.admin = false
- @user.register
- end
+ @user = assign_user_attributes({ admin: false, status: User.statuses[:registered] }) if @user.nil?
return if enforce_activation_user_limit(user: user_with_email(@user))
@@ -329,6 +324,13 @@ class AccountController < ApplicationController
end
end
+ def assign_user_attributes(attrs)
+ Users::SetAttributesService
+ .new(model: User.new, user: current_user, contract_class: EmptyContract)
+ .call(attrs)
+ .result
+ end
+
def register_plain_user(user)
user.attributes = permitted_params.user.transform_values do |val|
if val.is_a? String
diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rb
index d3def532ee7..ff8d50a85d0 100644
--- a/spec/controllers/account_controller_spec.rb
+++ b/spec/controllers/account_controller_spec.rb
@@ -562,6 +562,7 @@ describe AccountController, type: :controller do
expect(subject).to respond_with :success
expect(response).to render_template :register
expect(assigns[:user]).not_to be_nil
+ expect(assigns[:user].notification_settings.size).to eq(1)
end
end