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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Correctly continue activation after registration error
Oliver Günther5969d8239b9f
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rbindex c9cfb8982c4..edf3c7859c8 100644--- a/app/controllers/account_controller.rb+++ b/app/controllers/account_controller.rb@@ -322,9 +322,12 @@ class AccountController < ApplicationController# on-the-fly registration via omniauth or via auth sourceif pending_omniauth_registration?@user.assign_attributes permitted_params.user_register_via_omniauth- register_via_omniauth(session, @user.attributes)+ return register_via_omniauth(session, @user.attributes)else- register_and_login_via_authsource(@user, session, permitted_params)+ @user.attributes = permitted_params.user+ @user.activate+ @user.login = session[:auth_source_registration][:login]+ @user.auth_source_id = session[:auth_source_registration][:auth_source_id]endelse@user.attributes = permitted_params.user.transform_values do |val|@@ -337,17 +340,17 @@ class AccountController < ApplicationController@user.login = params[:user][:login].strip if params[:user][:login].present?@user.password = params[:user][:password]@user.password_confirmation = params[:user][:password_confirmation]+ end- call = ::Users::RegisterUserService.new(@user).call+ call = ::Users::RegisterUserService.new(@user).call- if call.success?- flash[:notice] = call.message.presence- login_user_if_active(call.result, just_registered: true)- else- flash[:error] = error = call.message- Rails.logger.error "Registration of user #{@user.login} failed: #{error}"- onthefly_creation_failed(@user, login: @user.login)- end+ if call.success?+ flash[:notice] = call.message.presence+ login_user_if_active(call.result, just_registered: true)+ else+ flash[:error] = error = call.message+ Rails.logger.error "Registration of user #{@user.login} failed: #{error}"+ onthefly_creation_failed(@user)endend@@ -483,21 +486,6 @@ class AccountController < ApplicationControllerHash(session[:auth_source_registration])[:omniauth]end- def register_and_login_via_authsource(_user, session, permitted_params)- @user.attributes = permitted_params.user- @user.activate- @user.login = session[:auth_source_registration][:login]- @user.auth_source_id = session[:auth_source_registration][:auth_source_id]-- if @user.save- session[:auth_source_registration] = nil- self.logged_user = @user- flash[:notice] = I18n.t(:notice_account_activated)- redirect_to controller: '/my', action: 'account'- end- # Otherwise render register view again- end-# Onthefly creation failed, display the registration form to fill/fix attributesdef onthefly_creation_failed(user, auth_source_options = {})@user = userdiff --git a/spec/features/users/self_registration_spec.rb b/spec/features/users/self_registration_spec.rbindex 433cec20361..9a4722e0521 100644--- a/spec/features/users/self_registration_spec.rb+++ b/spec/features/users/self_registration_spec.rb@@ -32,12 +32,8 @@ describe 'user self registration', type: :feature, js: true dolet(:admin) { FactoryBot.create :admin, password: 'Test123Test123', password_confirmation: 'Test123Test123' }let(:home_page) { Pages::Home.new }- context 'with "manual account activation"' do- before do- allow(Setting)- .to receive(:self_registration?)- .and_return true- end+ context 'with "manual account activation"',+ with_settings: { self_registration: Setting::SelfRegistration.manual.to_s } doit 'allows self registration on login page (Regression #28076)' dovisit signin_path