From 0708687ad5e9bd5491f55126887c15fc18c61f2b Mon Sep 17 00:00:00 2001 From: Dmitrii Date: Sun, 7 Aug 2022 19:29:35 +0200 Subject: [PATCH] [#41851] Blank Email reminders page when creating account manually --- app/controllers/account_controller.rb | 19 +++++++++---------- spec/controllers/account_controller_spec.rb | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 87f48cee4f..939c5047de 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -299,20 +299,19 @@ class AccountController < ApplicationController def registration_through_invitation! session[:auth_source_registration] = nil - if @user.nil? - @user = User.new(language: Setting.default_language) - elsif user_with_placeholder_name?(@user) - # force user to give their name - @user.firstname = nil - @user.lastname = nil - end + @user = Users::SetAttributesService.new( + model: @user || User.new, user: current_user, + contract_class: @user.nil? ? Users::CreateContract : Users::UpdateContract + ).call(@user.nil? ? { language: Setting.default_language } : { firstname: nil, lastname: nil }) + .result end def self_registration! if @user.nil? - @user = User.new - @user.admin = false - @user.register + @user = Users::SetAttributesService + .new(model: User.new, user: current_user, contract_class: Users::CreateContract) + .call(admin: false, status: User.statuses[:registered]) + .result end return if enforce_activation_user_limit(user: user_with_email(@user)) diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rb index d3def532ee..ff8d50a85d 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