From 08855805a9292eda3704094e0e9c196132b40738 Mon Sep 17 00:00:00 2001 From: olga-jwp Date: Tue, 14 Nov 2023 14:38:52 +0100 Subject: [PATCH 01/21] fix: switch to playlist_multiselect --- scripts/content-types/content-types.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/content-types/content-types.json b/scripts/content-types/content-types.json index e63b6baa0..2162962f5 100644 --- a/scripts/content-types/content-types.json +++ b/scripts/content-types/content-types.json @@ -326,7 +326,7 @@ "description": "The playlist ID to display on this hub page", "required": true, "details": { - "field_type": "playlist_select" + "field_type": "playlist_multiselect" } }, { From b3aa7394131227aa2713a5951c6047f2ae7be804 Mon Sep 17 00:00:00 2001 From: Filip Naumovski Date: Wed, 15 Nov 2023 16:52:23 +0100 Subject: [PATCH 02/21] feat(user): add ability to add password to a social account feat(user): add resend password reset email button --- public/locales/en/user.json | 10 ++++ public/locales/es/user.json | 10 ++++ src/components/Account/Account.tsx | 26 ++++++-- .../DeleteAccountModal/DeleteAccountModal.tsx | 1 - .../DeleteAccountPasswordWarning.module.scss | 54 +++++++++++++++++ .../DeleteAccountPasswordWarning.tsx | 59 +++++++++++++++++++ .../EditPasswordForm.module.scss | 17 ++++++ .../EditPasswordForm/EditPasswordForm.tsx | 43 ++++++++++---- src/containers/AccountModal/AccountModal.tsx | 7 ++- .../AccountModal/forms/EditPassword.tsx | 21 +++++-- 10 files changed, 227 insertions(+), 21 deletions(-) create mode 100644 src/components/DeleteAccountPasswordWarning/DeleteAccountPasswordWarning.module.scss create mode 100644 src/components/DeleteAccountPasswordWarning/DeleteAccountPasswordWarning.tsx diff --git a/public/locales/en/user.json b/public/locales/en/user.json index 2d7f31b6d..6b9844ef8 100644 --- a/public/locales/en/user.json +++ b/public/locales/en/user.json @@ -1,6 +1,9 @@ { "account": { "about_you": "Profile info", + "add_password": "Add password", + "add_password_error": "Failed to proceed to the Add Password screen. Please try again.", + "add_password_modal_text": "We sent instructions to {{email}} on how to add a password. If you don’t receive the email within a few minutes, check your spam folder or", "add_profile": "Add profile", "cancel": "Cancel", "confirm_password": "Confirm password", @@ -20,6 +23,10 @@ }, "title": "Delete account" }, + "delete_account_password_warning": { + "text": "To delete your account when using social media account(s) for sign-in, you will first need to add an account password and then initiate the deletion process again.", + "title": "Warning" + }, "edit_account": "Edit account", "edit_information": "Edit information", "edit_password": "Edit password", @@ -44,6 +51,9 @@ "manage_profiles": "Manage profiles", "other_registration_details": "Other registration details", "password": "Password", + "proceed_to_adding_a_password": "Proceed to adding a password", + "resend_mail": "resend the email.", + "resend_mail_error": "An error occurred while resending the email. Please try again.", "save": "Save", "security": "Password", "terms_and_tracking": "Legal & Marketing", diff --git a/public/locales/es/user.json b/public/locales/es/user.json index 4accc14c7..1081c26c7 100644 --- a/public/locales/es/user.json +++ b/public/locales/es/user.json @@ -1,6 +1,9 @@ { "account": { "about_you": "Información de perfil", + "add_password": "Agregar contraseña", + "add_password_error": "No se pudo pasar a la pantalla Agregar contraseña. Inténtalo de nuevo.", + "add_password_modal_text": "Enviamos instrucciones a {{email}} sobre cómo agregar una contraseña. Si no recibes el correo electrónico en unos minutos, revisa tu carpeta de spam o", "add_profile": "Añadir perfil", "cancel": "Cancelar", "confirm_password": "Confirmar contraseña", @@ -20,6 +23,10 @@ }, "title": "Borrar cuenta" }, + "delete_account_password_warning": { + "text": "Para eliminar su cuenta cuando utiliza cuentas de redes sociales para iniciar sesión, primero deberá agregar una contraseña de cuenta y luego iniciar el proceso de eliminación nuevamente.", + "title": "Advertencia" + }, "edit_account": "Editar cuenta", "edit_information": "Editar información", "edit_password": "Editar contraseña", @@ -44,6 +51,9 @@ "manage_profiles": "Administrar perfiles", "other_registration_details": "Otros detalles de registro", "password": "Contraseña", + "proceed_to_adding_a_password": "Proceda a agregar una contraseña", + "resend_mail": "reenvíe el correo electrónico.", + "resend_mail_error": "Se produjo un error al reenviar el correo electrónico. Inténtalo de nuevo.", "save": "Guardar", "security": "Contraseña", "terms_and_tracking": "Jurídico y marketing", diff --git a/src/components/Account/Account.tsx b/src/components/Account/Account.tsx index 60e4c2b92..09668834f 100644 --- a/src/components/Account/Account.tsx +++ b/src/components/Account/Account.tsx @@ -24,7 +24,7 @@ import useToggle from '#src/hooks/useToggle'; import { formatConsentsFromValues, formatConsents, formatConsentValues, formatConsentsToRegisterFields } from '#src/utils/collection'; import { addQueryParam } from '#src/utils/location'; import { useAccountStore } from '#src/stores/AccountStore'; -import { exportAccountData, updateConsents, updateUser } from '#src/stores/AccountController'; +import { exportAccountData, resetPassword, updateConsents, updateUser } from '#src/stores/AccountController'; type Props = { panelClassName?: string; @@ -67,6 +67,11 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true } shallow, ); + // users authenticated with social (register_source: facebook, google, twitter) do not have password by default + const registerSource = customer?.metadata?.register_source; + const isSocialLogin = (registerSource && registerSource !== 'inplayer') || false; + const shouldAddPassword = (isSocialLogin && !customer?.metadata?.has_password) || false; + const [termsConsents, nonTermsConsents] = useMemo(() => { const terms: Consent[] = []; const nonTerms: Consent[] = []; @@ -173,7 +178,14 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true } }; } - const editPasswordClickHandler = () => { + const editPasswordClickHandler = async () => { + if (!customer) { + return; + } + if (isSocialLogin && shouldAddPassword) { + await resetPassword(customer.email, ''); + return navigate(addQueryParam(location, 'u', 'add-password')); + } const modal = canChangePasswordWithOldPassword ? 'edit-password' : 'reset-password'; navigate(addQueryParam(location, 'u', modal)); }; @@ -269,7 +281,13 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true } }), formSection({ label: t('account.security'), - editButton: