From b7335186a5a8611596868547139adf50d6fe1a0e Mon Sep 17 00:00:00 2001 From: adrienne-deriv <103016120+adrienne-deriv@users.noreply.github.com> Date: Fri, 24 Jan 2025 22:43:16 +0800 Subject: [PATCH] Adrienne / Reset password redirect to OIDC endpoint (#18028) * feat: store redirect metadata for traders hub from os-redirect * chore: change redirect url for traders hub as requested * chore: fixed an issue where after resetting password, user is not using oidc * chore: remove redirection to login auth for reset password if auth enabled --- .../ResetPasswordModal/reset-password-modal.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/src/App/Containers/ResetPasswordModal/reset-password-modal.tsx b/packages/core/src/App/Containers/ResetPasswordModal/reset-password-modal.tsx index c926f2d3ac52..a9868eaf364c 100644 --- a/packages/core/src/App/Containers/ResetPasswordModal/reset-password-modal.tsx +++ b/packages/core/src/App/Containers/ResetPasswordModal/reset-password-modal.tsx @@ -3,10 +3,12 @@ import classNames from 'classnames'; import { Formik, Form, FormikHelpers, FormikErrors } from 'formik'; import { Button, Dialog, PasswordInput, PasswordMeter, Text } from '@deriv/components'; import { redirectToLogin, validPassword, validLength, getErrorMessages, WS, removeActionParam } from '@deriv/shared'; +import { requestOidcAuthentication } from '@deriv-com/auth-client'; import { getLanguage, localize, Localize } from '@deriv/translations'; import { observer, useStore } from '@deriv/stores'; import { TSocketError, TSocketRequest, TSocketResponse } from '@deriv/api/types'; import { useDevice } from '@deriv-com/ui'; +import { useOauth2 } from '@deriv/hooks'; type TResetPasswordModalValues = { password: string; @@ -25,6 +27,8 @@ const ResetPasswordModal = observer(() => { } = ui; const { isDesktop } = useDevice(); + const { isOAuth2Enabled } = useOauth2({ handleLogout: async () => {} }); + const onResetComplete = ( error: TSocketError<'reset_password'>['error'] | null, actions: FormikHelpers @@ -49,7 +53,13 @@ const ResetPasswordModal = observer(() => { setPreventRedirectToHub(false); actions.setStatus({ reset_complete: true }); logoutClient().then(() => { - redirectToLogin(false, getLanguage(), false); + if (isOAuth2Enabled) { + requestOidcAuthentication({ + redirectCallbackUri: `${window.location.origin}/callback`, + }); + } else { + redirectToLogin(false, getLanguage(), false); + } }); };