Merge pull request #10761 from demarches-simplifiees/fix-10754

ETQ Instructeur, si je n'ai pas vérifié mon email je dois quand même recevoir un email avec login token
This commit is contained in:
Mathieu Magnin 2024-09-06 14:14:54 +00:00 committed by GitHub
commit 8d68bebaed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 0 deletions

View file

@ -92,6 +92,8 @@ class Users::SessionsController < Devise::SessionsController
# redirect to root_path otherwise # redirect to root_path otherwise
if instructeur_signed_in? if instructeur_signed_in?
current_user.update!(email_verified_at: Time.zone.now)
redirect_to after_sign_in_path_for(:user) redirect_to after_sign_in_path_for(:user)
else else
redirect_to new_user_session_path redirect_to new_user_session_path

View file

@ -36,6 +36,8 @@ class InstructeurMailer < ApplicationMailer
@login_token = login_token @login_token = login_token
subject = "Connexion sécurisée à #{Current.application_name}" subject = "Connexion sécurisée à #{Current.application_name}"
bypass_unverified_mail_protection!
mail(to: instructeur.email, subject: subject) mail(to: instructeur.email, subject: subject)
end end

View file

@ -217,6 +217,7 @@ describe Users::SessionsController, type: :controller do
it { is_expected.to redirect_to root_path } it { is_expected.to redirect_to root_path }
it { expect(controller.current_instructeur).to eq(instructeur) } it { expect(controller.current_instructeur).to eq(instructeur) }
it { expect(controller).to have_received(:trust_device) } it { expect(controller).to have_received(:trust_device) }
it { expect(controller.current_instructeur.user.email_verified_at).not_to be_nil }
end end
context 'when the token is invalid' do context 'when the token is invalid' do

View file

@ -24,6 +24,8 @@ RSpec.describe InstructeurMailer, type: :mailer do
let(:token) { SecureRandom.hex } let(:token) { SecureRandom.hex }
subject { described_class.send_login_token(user, token) } subject { described_class.send_login_token(user, token) }
it { expect(subject[BalancerDeliveryMethod::BYPASS_UNVERIFIED_MAIL_PROTECTION]).to be_present }
context 'without SafeMailer configured' do context 'without SafeMailer configured' do
it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) } it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) }
end end