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

Don't show an error when the user just registered

Oliver Günther841e1149c282
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index 71890d2d28b..c9cfb8982c4 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -420,7 +420,7 @@ class AccountController < ApplicationController
# setting params back_url to be used by redirect_after_login
params[:back_url] = session.delete :back_url if session.include?(:back_url)
- if session[:just_registered]
+ if just_registered || session[:just_registered]
finish_registration! user
else
login_user! user
@@ -463,10 +463,16 @@ class AccountController < ApplicationController
def login_user_if_active(user, just_registered:)
if user.active?
successful_authentication(user, just_registered: just_registered)
- else
+ return
+ end
+
+ # Show an appropriate error unless
+ # the user was just registered
+ if !(just_registered && user.registered?)
account_inactive(user, flash_now: false)
- redirect_to signin_path(back_url: params[:back_url])
end
+
+ redirect_to signin_path(back_url: params[:back_url])
end
def pending_auth_source_registration?
diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb
index e23f2b764fb..0934ef3e139 100644
--- a/spec/features/auth/omniauth_spec.rb
+++ b/spec/features/auth/omniauth_spec.rb
@@ -63,7 +63,7 @@ describe 'Omniauth authentication', type: :feature do
context 'sign in existing user' do
it 'should redirect to back url' do
visit account_lost_password_path
- click_link("Omniauth Developer", :match => :first)
+ click_link("Omniauth Developer", match: :first, visible: :all)
fill_in('first_name', with: user.firstname)
fill_in('last_name', with: user.lastname)
fill_in('email', with: user.mail)
@@ -138,6 +138,7 @@ describe 'Omniauth authentication', type: :feature do
fill_in('email', with: user.mail)
click_link_or_button 'Sign In'
+ expect(page).to have_content "Last name can't be blank"
# on register form, we are prompted for a last name
within('#content') do
fill_in('user_lastname', with: user.lastname)