From 992d005db4b117600089c5aca72c4b21385a6a60 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 13 Oct 2023 17:13:40 +0200 Subject: [PATCH] [CL-3870] Check if Hoplr email was confirmed --- back/app/controllers/omniauth_callback_controller.rb | 3 ++- .../commercial/id_hoplr/app/lib/id_hoplr/hoplr_omniauth.rb | 4 ++++ back/lib/omniauth_methods/base.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/back/app/controllers/omniauth_callback_controller.rb b/back/app/controllers/omniauth_callback_controller.rb index 04436feeef5f..c567172d91d8 100644 --- a/back/app/controllers/omniauth_callback_controller.rb +++ b/back/app/controllers/omniauth_callback_controller.rb @@ -190,7 +190,8 @@ def update_user!(auth, user, authver_method) attrs = authver_method.updateable_user_attrs update_hash = authver_method.profile_to_user_attrs(auth).slice(*attrs).compact update_hash.delete(:remote_avatar_url) if user.avatar.present? # don't overwrite avatar if already present - user.confirm! # confirm user email if not already confirmed + # confirm user email if not already confirmed + user.confirm! if authver_method.email_confirmed?(auth) if authver_method.overwrite_user_attrs? user.update_merging_custom_fields!(update_hash) diff --git a/back/engines/commercial/id_hoplr/app/lib/id_hoplr/hoplr_omniauth.rb b/back/engines/commercial/id_hoplr/app/lib/id_hoplr/hoplr_omniauth.rb index e6bb1d4b0329..d2f84ba681b3 100644 --- a/back/engines/commercial/id_hoplr/app/lib/id_hoplr/hoplr_omniauth.rb +++ b/back/engines/commercial/id_hoplr/app/lib/id_hoplr/hoplr_omniauth.rb @@ -54,5 +54,9 @@ def issuer def updateable_user_attrs %i[first_name last_name] end + + def email_confirmed?(auth) + auth.info.email_verified + end end end diff --git a/back/lib/omniauth_methods/base.rb b/back/lib/omniauth_methods/base.rb index ba93e8b69c82..61209f3598f8 100644 --- a/back/lib/omniauth_methods/base.rb +++ b/back/lib/omniauth_methods/base.rb @@ -42,6 +42,10 @@ def email_always_present? true end + def email_confirmed?(_auth) + true + end + def verification_prioritized? raise NotImplementedError end