2019-05-13-02 (#3863)

2019-05-13-02
This commit is contained in:
Pierre de La Morinerie 2019-05-13 16:32:55 +02:00 committed by GitHub
commit 74ca5c744c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 9 deletions

View file

@ -30,7 +30,7 @@ class FranceConnect::ParticulierController < ApplicationController
private private
def redirect_to_login_if_fc_aborted def redirect_to_login_if_fc_aborted
if params[:code].empty? if params[:code].blank?
redirect_to new_user_session_path redirect_to new_user_session_path
end end
end end

View file

@ -26,12 +26,10 @@ class Users::RegistrationsController < Devise::RegistrationsController
if existing_user.present? if existing_user.present?
if existing_user.confirmed? if existing_user.confirmed?
UserMailer.new_account_warning(existing_user).deliver_later UserMailer.new_account_warning(existing_user).deliver_later
flash.notice = t('devise.registrations.signed_up_but_unconfirmed')
return redirect_to root_path
else else
existing_user.resend_confirmation_instructions existing_user.resend_confirmation_instructions
return redirect_to after_inactive_sign_up_path_for(existing_user)
end end
return redirect_to after_inactive_sign_up_path_for(existing_user)
end end
super super

View file

@ -45,6 +45,7 @@ class NotificationMailer < ApplicationMailer
@logo_url = attachments[logo_filename].url @logo_url = attachments[logo_filename].url
rescue StandardError => e rescue StandardError => e
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ? # A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
Raven.extra_context(procedure_id: dossier.procedure.id)
Raven.capture_exception(e) Raven.capture_exception(e)
end end
end end

View file

@ -25,6 +25,12 @@ describe FranceConnect::ParticulierController, type: :controller do
subject { get :callback, params: { code: code } } subject { get :callback, params: { code: code } }
context 'when params are missing' do
subject { get :callback }
it { is_expected.to redirect_to(new_user_session_path) }
end
context 'when param code is missing' do context 'when param code is missing' do
let(:code) { nil } let(:code) { nil }

View file

@ -74,9 +74,13 @@ describe Users::RegistrationsController, type: :controller do
before { subject } before { subject }
it { expect(response).to redirect_to(root_path) } it 'sends an email to the user, stating that the account already exists' do
it { expect(flash.notice).to eq(I18n.t('devise.registrations.signed_up_but_unconfirmed')) } expect(UserMailer).to have_received(:new_account_warning)
it { expect(UserMailer).to have_received(:new_account_warning) } end
it 'avoids leaking information about the account existence, by redirecting to the same page than normal signup' do
expect(response).to redirect_to(new_user_confirmation_path(user: { email: user[:email] }))
end
end end
context 'and the user is not confirmed' do context 'and the user is not confirmed' do
@ -87,8 +91,13 @@ describe Users::RegistrationsController, type: :controller do
subject subject
end end
it { expect(response).to redirect_to(new_user_confirmation_path(user: { email: user[:email] })) } it 'does not send a warning email' do
it { expect(UserMailer).not_to have_received(:new_account_warning) } expect(UserMailer).not_to have_received(:new_account_warning)
end
it 'avoids leaking information about the account existence, by redirecting to the same page than normal signup' do
expect(response).to redirect_to(new_user_confirmation_path(user: { email: user[:email] }))
end
end end
end end
end end