Merge pull request #10758 from demarches-simplifiees/fix-10752

ETQ Instructeur je veux avoir mon email vérifié si je reset mon mdp
This commit is contained in:
LeSim 2024-09-06 13:36:29 +00:00 committed by GitHub
commit 723ea310ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View file

@ -5,6 +5,7 @@ class Users::PasswordsController < Devise::PasswordsController
after_action :try_to_authenticate_instructeur, only: [:update] after_action :try_to_authenticate_instructeur, only: [:update]
after_action :try_to_authenticate_administrateur, only: [:update] after_action :try_to_authenticate_administrateur, only: [:update]
after_action :update_email_verified_at, only: [:update]
# GET /resource/password/new # GET /resource/password/new
# def new # def new
@ -62,4 +63,10 @@ class Users::PasswordsController < Devise::PasswordsController
end end
end end
end end
def update_email_verified_at
if user_signed_in?
current_user.update!(email_verified_at: Time.zone.now)
end
end
end end

View file

@ -38,6 +38,19 @@ describe Users::PasswordsController, type: :controller do
expect(subject.current_user).to eq(user) expect(subject.current_user).to eq(user)
expect(subject.current_administrateur).to eq(administrateur) expect(subject.current_administrateur).to eq(administrateur)
end end
it "marks user's email as verified" do
expect do
put :update, params: {
user: {
reset_password_token: @token,
password: "mot de passe super secret",
password_confirmation: "mot de passe super secret"
}
}
end.to change { user.reload.email_verified_at }
.from(nil).to(anything)
end
end end
end end