From d8b105cd51f04e671a1c9aa6873dbd7d016478f0 Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:40:05 +0530 Subject: [PATCH] chore: remove basic auth (#1255) --- .github/workflows/release-stable-version.yml | 2 +- config/config.toml | 1 - src/context/AuthInfoProvider.res | 15 - src/context/TokenContextProvider.res | 8 +- src/context/UserPrefContext.res | 3 +- src/entryPoints/AcceptInvite.res | 91 ------ .../AuthModule/AuthModuleHooks.res | 6 +- .../AuthModule/AuthProviderTypes.res | 2 +- .../AuthModule/BasicAuth/BasicAuth.res | 275 ------------------ .../AuthModule/BasicAuth/BasicAuthEntry.res | 10 - .../AuthModule/BasicAuth/BasicAuthScreen.res | 129 -------- .../AuthModule/BasicAuth/BasicAuthTypes.res | 12 - .../AuthModule/BasicAuth/BasicAuthUtils.res | 85 ------ .../AuthModule/BasicAuth/BasicAuthWrapper.res | 35 --- .../BasicAuth/BasicDecisionScreen.res | 22 -- .../BasicAuth/BasicEmailVerifyScreen.res | 47 --- .../BasicAuth/BasicInviteFromEmail.res | 50 ---- .../AuthModule/Common/CommonAuthHooks.res | 8 - .../PreLoginModule/AcceptInviteScreen.res | 6 +- .../PreLoginModule/MerchantSelectScreen.res | 2 +- .../PreLoginModule/ResetPassword.res | 2 +- .../PreLoginModule/VerifyUserFromEmail.res | 2 +- .../AuthModule/TwoFaAuth/TwoFaAuth.res | 5 +- src/entryPoints/FeatureFlagUtils.res | 2 - src/entryPoints/HyperSwitchApp.res | 9 +- src/entryPoints/HyperSwitchEntry.res | 6 +- src/hooks/AuthHooks.res | 2 +- src/screens/APIUtils/APIUtils.res | 14 - src/screens/APIUtils/APIUtilsTypes.res | 7 - src/screens/Home/Home.res | 5 +- src/screens/Home/HomeV2.res | 4 +- .../BusinessMapping/BusinessProfile.res | 3 +- .../HSwitchProfile/HSwitchProfileSettings.res | 4 +- src/screens/Sidebar/Sidebar.res | 2 +- src/screens/SwitchMerchant/SwitchMerchant.res | 19 +- .../OldUserManagement/InviteUsers.res | 23 +- 36 files changed, 39 insertions(+), 879 deletions(-) delete mode 100644 src/entryPoints/AcceptInvite.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicAuth.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicAuthEntry.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicAuthScreen.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicAuthTypes.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicAuthUtils.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicAuthWrapper.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicDecisionScreen.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicEmailVerifyScreen.res delete mode 100644 src/entryPoints/AuthModule/BasicAuth/BasicInviteFromEmail.res diff --git a/.github/workflows/release-stable-version.yml b/.github/workflows/release-stable-version.yml index 920960f71..155cf2aca 100644 --- a/.github/workflows/release-stable-version.yml +++ b/.github/workflows/release-stable-version.yml @@ -163,4 +163,4 @@ jobs: with: name: release-notes.md path: release-notes.md - if-no-files-found: error \ No newline at end of file + if-no-files-found: error diff --git a/config/config.toml b/config/config.toml index 5b5eb1ba3..3f012b39d 100644 --- a/config/config.toml +++ b/config/config.toml @@ -38,7 +38,6 @@ global_search=false dispute_analytics=false configure_pmts=false branding=false -totp=false live_users_counter=false granularity=false custom_webhook_headers=false diff --git a/src/context/AuthInfoProvider.res b/src/context/AuthInfoProvider.res index 3e0eb37ee..63b60e2d9 100644 --- a/src/context/AuthInfoProvider.res +++ b/src/context/AuthInfoProvider.res @@ -31,21 +31,6 @@ let make = (~children) => { switch newAuthStatus { | LoggedIn(info) => switch info { - | BasicAuth(basicInfo) => - switch basicInfo.token { - | Some(token) => - if !(token->LogicUtils.isEmptyString) { - setAuth(_ => newAuthStatus) - BasicAuthUtils.setBasicAuthResToStorage(basicInfo) - } else { - setAuth(_ => LoggedOut) - CommonAuthUtils.clearLocalStorage() - } - | None => { - setAuth(_ => LoggedOut) - CommonAuthUtils.clearLocalStorage() - } - } | Auth(totpInfo) => if totpInfo.token->Option.isSome { setAuth(_ => newAuthStatus) diff --git a/src/context/TokenContextProvider.res b/src/context/TokenContextProvider.res index 93f04d76d..9b26adf2d 100644 --- a/src/context/TokenContextProvider.res +++ b/src/context/TokenContextProvider.res @@ -6,7 +6,7 @@ type tokenContextObjectType = { setToken: (option => option) => unit, tokenDetailsDict: Dict.t, setTokenDetailsDict: (Dict.t => Dict.t) => unit, - parentAuthInfo: option, + parentAuthInfo: option, } let defaultTokenObj = { @@ -14,7 +14,7 @@ let defaultTokenObj = { setToken: defaultTokenSetter, tokenDetailsDict: Dict.make(), setTokenDetailsDict: defaultDictSetter, - parentAuthInfo: Some(BasicAuthUtils.getBasicAuthInfo(JSON.Encode.object(Dict.make()))), + parentAuthInfo: Some(AuthUtils.getAuthInfo(JSON.Encode.object(Dict.make()))), } let tokenContext = React.createContext(defaultTokenObj) @@ -31,9 +31,7 @@ let make = (~children) => { let tokenContextObjext = React.useMemo(() => { let parentAuthInfo = Some( - BasicAuthUtils.getBasicAuthInfo( - tokenDetailsDict->LogicUtils.getJsonObjectFromDict("tokenDict"), - ), + AuthUtils.getAuthInfo(tokenDetailsDict->LogicUtils.getJsonObjectFromDict("tokenDict")), ) { diff --git a/src/context/UserPrefContext.res b/src/context/UserPrefContext.res index 3dc31563e..8d966bd46 100644 --- a/src/context/UserPrefContext.res +++ b/src/context/UserPrefContext.res @@ -39,8 +39,7 @@ let make = (~children) => { let username = switch authStatus { | LoggedIn(authType) => switch authType { - | BasicAuth(basicAuthInfo) => basicAuthInfo.name->Option.getOr("") - | _ => "" + | Auth(_) => "" } | _ => "" } diff --git a/src/entryPoints/AcceptInvite.res b/src/entryPoints/AcceptInvite.res deleted file mode 100644 index 61d70dc32..000000000 --- a/src/entryPoints/AcceptInvite.res +++ /dev/null @@ -1,91 +0,0 @@ -@react.component -let make = () => { - open APIUtils - open LogicUtils - - let showToast = ToastState.useShowToast() - let {authStatus} = React.useContext(AuthInfoProvider.authStatusContext) - let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext) - let {setAuthStatus} = React.useContext(AuthInfoProvider.authStatusContext) - let updateDetails = useUpdateMethod() - let (merchantData, setMerchantData) = React.useState(_ => []) - let getURL = useGetURL() - let handleLogout = useHandleLogout() - - React.useEffect(() => { - let acceptInvitedata = switch authStatus { - | LoggedIn(info) => - switch info { - | BasicAuth(basicInfo) => basicInfo.merchants - | _ => None - } - | _ => None - } - - switch acceptInvitedata { - | Some(arr) => - if arr->Array.length > 0 { - setMerchantData(_ => arr) - RescriptReactRouter.replace(GlobalVars.appendDashboardPath(~url="/accept-invite")) - } else { - handleLogout()->ignore - } - | None => handleLogout()->ignore - } - - None - }, []) - - let onClickLoginToDashboard = async () => { - try { - let url = getURL(~entityName=USERS, ~userType=#ACCEPT_INVITE, ~methodType=Post) - let acceptedMerchantIds = merchantData->Array.reduce([], (acc, ele) => { - let merchantDataDict = ele->getDictFromJsonObject - if merchantDataDict->getBool("is_active", false) { - acc->Array.push(merchantDataDict->getString("merchant_id", "")->JSON.Encode.string) - } - acc - }) - let body = - [ - ("merchant_ids", acceptedMerchantIds->JSON.Encode.array), - ("need_dashboard_entry_response", true->JSON.Encode.bool), - ]->getJsonFromArrayOfJson - let res = await updateDetails(url, body, Post) - let typedInfo = res->BasicAuthUtils.getBasicAuthInfo - if typedInfo.token->Option.isSome { - open AuthProviderTypes - open HSLocalStorage - removeItemFromLocalStorage(~key="accept_invite_data") - setAuthStatus(LoggedIn(BasicAuth(typedInfo))) - setDashboardPageState(_ => #HOME) - } else { - showToast(~message="Failed to sign in, Try again", ~toastType=ToastError) - handleLogout()->ignore - } - } catch { - | _ => () - } - } - - let acceptInviteUpdate = index => { - let merchantDataUpdated = - merchantData - ->JSON.stringifyAny - ->Option.getOr("") - ->safeParse - ->JSON.Decode.array - ->Option.getOr([]) - - merchantDataUpdated - ->getValueFromArray(index, JSON.Encode.null) - ->getDictFromJsonObject - ->Dict.set("is_active", true->JSON.Encode.bool) - - setMerchantData(_ => merchantDataUpdated) - } - - -} diff --git a/src/entryPoints/AuthModule/AuthModuleHooks.res b/src/entryPoints/AuthModule/AuthModuleHooks.res index f5455fe86..03fa6eac8 100644 --- a/src/entryPoints/AuthModule/AuthModuleHooks.res +++ b/src/entryPoints/AuthModule/AuthModuleHooks.res @@ -95,7 +95,7 @@ let useAuthMethods = (): authMethodProps => { | None => false } let emailFeatureFlagEnable = featureFlagValues.email - let isTotpFeatureDisable = featureFlagValues.totp + // let isTotpFeatureDisable = featureFlagValues.totp let isLiveMode = featureFlagValues.isLiveMode @@ -108,10 +108,10 @@ let useAuthMethods = (): authMethodProps => { } else if isSingUpAllowedinPassword { // Singup is allowed if email feature flag and allow_signup in the passowrd method is true (true, PASSWORD) - } else if !isTotpFeatureDisable && emailFeatureFlagEnable { + } else if emailFeatureFlagEnable { // Singup is allowed if totp feature is disable and email feature is enabled (true, MAGIC_LINK) - } else if !isTotpFeatureDisable { + } else if !isLiveMode { // Singup is allowed if totp feature is disable (true, PASSWORD) } else { diff --git a/src/entryPoints/AuthModule/AuthProviderTypes.res b/src/entryPoints/AuthModule/AuthProviderTypes.res index d06126b49..111cc2771 100644 --- a/src/entryPoints/AuthModule/AuthProviderTypes.res +++ b/src/entryPoints/AuthModule/AuthProviderTypes.res @@ -6,7 +6,7 @@ type preLoginType = { type authInfo = {token: option} -type authType = BasicAuth(BasicAuthTypes.basicAuthInfo) | Auth(authInfo) +type authType = Auth(authInfo) type authStatus = | LoggedOut diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicAuth.res b/src/entryPoints/AuthModule/BasicAuth/BasicAuth.res deleted file mode 100644 index b9db1f7a7..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicAuth.res +++ /dev/null @@ -1,275 +0,0 @@ -@react.component -let make = (~authType, ~setAuthType) => { - open BasicAuthUtils - open APIUtils - open CommonAuthForm - open GlobalVars - open LogicUtils - let {setAuthStatus} = React.useContext(AuthInfoProvider.authStatusContext) - let getURL = useGetURL() - let url = RescriptReactRouter.useUrl() - let mixpanelEvent = MixpanelHook.useSendEvent() - let initialValues = Dict.make()->JSON.Encode.object - let clientCountry = HSwitchUtils.getBrowswerDetails().clientCountry - let country = clientCountry.isoAlpha2->CountryUtils.getCountryCodeStringFromVarient - let showToast = ToastState.useShowToast() - let updateDetails = useUpdateMethod(~showErrorToast=false) - let (email, setEmail) = React.useState(_ => "") - let featureFlagValues = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - let authId = HyperSwitchEntryUtils.getSessionData(~key="auth_id") - - let handleAuthError = e => { - open CommonAuthUtils - let error = e->parseErrorMessage - switch error.code->errorSubCodeMapper { - | UR_03 => "An account already exists with this email" - | UR_05 => { - setAuthType(_ => CommonAuthTypes.ResendVerifyEmail) - "Kindly verify your account" - } - | UR_16 => "Please use a valid email" - | UR_01 => "Incorrect email or password" - | _ => "Register failed, Try again" - } - } - - let getUserWithEmail = async body => { - try { - let url = getURL( - ~entityName=USERS, - ~userType=#CONNECT_ACCOUNT, - ~methodType=Post, - ~queryParamerters=Some(`auth_id=${authId}`), - ) - let res = await updateDetails(url, body, Post) - let valuesDict = res->getDictFromJsonObject - let magicLinkSent = valuesDict->LogicUtils.getBool("is_email_sent", false) - - if magicLinkSent { - setAuthType(_ => MagicLinkEmailSent) - } else { - showToast(~message="Failed to send an email, Try again", ~toastType=ToastError) - } - } catch { - | Exn.Error(e) => showToast(~message={e->handleAuthError}, ~toastType=ToastError) - } - Nullable.null - } - - let getUserWithEmailPassword = async (body, userType) => { - try { - let url = getURL(~entityName=USERS, ~userType, ~methodType=Post) - let res = await updateDetails(url, body, Post) - setAuthStatus(LoggedIn(BasicAuth(res->BasicAuthUtils.getBasicAuthInfo))) - } catch { - | Exn.Error(e) => showToast(~message={e->handleAuthError}, ~toastType=ToastError) - } - Nullable.null - } - - let openPlayground = _ => { - open CommonAuthUtils - let body = getEmailPasswordBody(playgroundUserEmail, playgroundUserPassword, country) - getUserWithEmailPassword(body, #SIGNINV2)->ignore - HSLocalStorage.setIsPlaygroundInLocalStorage(true) - } - - let setResetPassword = async body => { - try { - let url = getURL(~entityName=USERS, ~userType=#RESET_PASSWORD, ~methodType=Post) - let _ = await updateDetails(url, body, Post) - LocalStorage.clear() - showToast(~message=`Password Changed Successfully`, ~toastType=ToastSuccess) - setAuthType(_ => LoginWithEmail) - } catch { - | _ => showToast(~message="Password Reset Failed, Try again", ~toastType=ToastError) - } - Nullable.null - } - - let setForgetPassword = async body => { - try { - let url = getURL( - ~entityName=USERS, - ~userType=#FORGOT_PASSWORD, - ~methodType=Post, - ~queryParamerters=Some(`auth_id=${authId}`), - ) - let _ = await updateDetails(url, body, Post) - setAuthType(_ => ForgetPasswordEmailSent) - showToast(~message="Please check your registered e-mail", ~toastType=ToastSuccess) - } catch { - | _ => showToast(~message="Forgot Password Failed, Try again", ~toastType=ToastError) - } - Nullable.null - } - - let resendVerifyEmail = async body => { - try { - let url = getURL( - ~entityName=USERS, - ~userType=#VERIFY_EMAIL_REQUEST, - ~methodType=Post, - ~queryParamerters=Some(`auth_id=${authId}`), - ) - let _ = await updateDetails(url, body, Post) - setAuthType(_ => ResendVerifyEmailSent) - showToast(~message="Please check your registered e-mail", ~toastType=ToastSuccess) - } catch { - | _ => showToast(~message="Resend mail failed, Try again", ~toastType=ToastError) - } - Nullable.null - } - - let logMixpanelEvents = email => { - open CommonAuthTypes - switch authType { - | LoginWithPassword => mixpanelEvent(~eventName=`signin_using_email&password`, ~email) - | LoginWithEmail => mixpanelEvent(~eventName=`signin_using_magic_link`, ~email) - | SignUP => mixpanelEvent(~eventName=`signup_using_magic_link`, ~email) - | _ => () - } - } - - let onSubmit = async (values, _) => { - try { - open CommonAuthUtils - let valuesDict = values->getDictFromJsonObject - let email = valuesDict->getString("email", "") - setEmail(_ => email) - logMixpanelEvents(email) - - let _ = await ( - switch (featureFlagValues.email, authType) { - | (true, SignUP) | (true, LoginWithEmail) => { - let body = getEmailBody(email, ~country) - getUserWithEmail(body) - } - - | (true, ResendVerifyEmail) => - let body = email->getEmailBody - resendVerifyEmail(body) - - | (false, SignUP) => { - let password = getString(valuesDict, "password", "") - let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, #SIGNUP) - } - | (_, LoginWithPassword) => { - let password = getString(valuesDict, "password", "") - let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, #SIGNINV2) - } - | (_, ResetPassword) => { - let queryDict = url.search->getDictFromUrlSearchParams - let password_reset_token = queryDict->Dict.get("token")->Option.getOr("") - let password = getString(valuesDict, "create_password", "") - let body = getResetpasswordBodyJson(password, password_reset_token) - setResetPassword(body) - } - | _ => - switch (featureFlagValues.email, authType) { - | (true, ForgetPassword) => - let body = email->getEmailBody - - setForgetPassword(body) - | _ => Promise.make((resolve, _) => resolve(Nullable.null)) - } - } - ) - CommonAuthUtils.setUserInMixpanel(email) - } catch { - | _ => showToast(~message="Something went wrong, Try again", ~toastType=ToastError) - } - Nullable.null - } - - let resendEmail = () => { - open CommonAuthUtils - let body = email->getEmailBody - switch authType { - | MagicLinkEmailSent => getUserWithEmail(body)->ignore - | ForgetPasswordEmailSent => setForgetPassword(body)->ignore - | ResendVerifyEmailSent => resendVerifyEmail(body)->ignore - | _ => () - } - } - - let submitBtnText = switch authType { - | LoginWithPassword | LoginWithEmail => "Continue" - | ResetPassword => "Confirm" - | ForgetPassword => "Reset password" - | ResendVerifyEmail => "Send mail" - | _ => "Get started, for free!" - } - - let validateKeys = switch authType { - | ForgetPassword - | ResendVerifyEmail - | LoginWithEmail => ["email"] - | SignUP => featureFlagValues.email ? ["email"] : ["email", "password"] - | LoginWithPassword => ["email"] - | ResetPassword => ["create_password", "comfirm_password"] - | _ => [] - } - - React.useEffect(() => { - if url.hash === "playground" { - openPlayground() - } - None - }, []) - let note = CommonAuthHooks.useNote(authType, setAuthType, featureFlagValues.email) - validateForm(values, validateKeys)} - onSubmit - render={({handleSubmit}) => { - <> - -
- {switch authType { - | LoginWithPassword => - | ForgetPassword => - - - - | LoginWithEmail - | ResendVerifyEmail - | SignUP => - featureFlagValues.email ? : - | ResetPassword => - | MagicLinkEmailSent | ForgetPasswordEmailSent | ResendVerifyEmailSent => - - | _ => React.null - }} -
- {switch authType { - | LoginWithPassword - | LoginWithEmail - | ResetPassword - | ForgetPassword - | ResendVerifyEmail - | SignUP => - - | _ => React.null - }} -
- -
{note}
-
- - - }} - /> -} diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicAuthEntry.res b/src/entryPoints/AuthModule/BasicAuth/BasicAuthEntry.res deleted file mode 100644 index 2a265d7b4..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicAuthEntry.res +++ /dev/null @@ -1,10 +0,0 @@ -@react.component -let make = () => { - - - - - - - -} diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicAuthScreen.res b/src/entryPoints/AuthModule/BasicAuth/BasicAuthScreen.res deleted file mode 100644 index 0be870ca9..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicAuthScreen.res +++ /dev/null @@ -1,129 +0,0 @@ -open CommonAuthUtils - -module BasicAuthPage = { - open FramerMotion.Motion - open CommonAuthTypes - @react.component - let make = (~authType, ~setAuthType, ~mode, ~setMode) => { - let {testLiveToggle, branding} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - - let (logoVariant, iconUrl) = switch (Window.env.logoUrl, branding) { - | (Some(url), true) => (IconWithURL, Some(url)) - | (Some(url), false) => (IconWithURL, Some(url)) - | _ => (IconWithText, None) - } - let screen = -
-
- - - -
-
-
- -
-
-
-
- -
-
- -
- -
-
-
- - - -
- - - {screen} - - } -} - -@react.component -let make = () => { - open CommonAuthTypes - - let url = RescriptReactRouter.useUrl() - let (mode, setMode) = React.useState(_ => TestButtonMode) - let {isLiveMode, email: isMagicLinkEnabled} = - HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - - let authInitState = LoginWithPassword - let (authType, setAuthType) = React.useState(_ => authInitState) - - let (actualAuthType, setActualAuthType) = React.useState(_ => authInitState) - - React.useEffect(() => { - if isLiveMode { - setMode(_ => LiveButtonMode) - } else { - setMode(_ => TestButtonMode) - } - - switch url.path { - | list{"user", "verify_email"} => setActualAuthType(_ => EmailVerify) - | list{"login"} => - setActualAuthType(_ => isMagicLinkEnabled ? LoginWithEmail : LoginWithPassword) - | list{"user", "set_password"} => setActualAuthType(_ => ResetPassword) - | list{"user", "accept_invite_from_email"} => setActualAuthType(_ => ActivateFromEmail) - | list{"forget-password"} => setActualAuthType(_ => ForgetPassword) - | list{"register"} => - // In Live mode users are not allowed to singup directly - !isLiveMode ? setActualAuthType(_ => SignUP) : AuthUtils.redirectToLogin() - | _ => () - } - - None - }, [url.path]) - - React.useEffect(() => { - if authType != actualAuthType { - setAuthType(_ => actualAuthType) - } - None - }, [actualAuthType]) - - React.useEffect(() => { - switch (authType, url.path) { - | ( - LoginWithEmail | LoginWithPassword, - list{"user", "verify_email"} - | list{"user", "accept_invite_from_email"} - | list{"user", "login"} - | list{"user", "set_password"} - | list{"register", ..._}, - ) => () // to prevent duplicate push - | (LoginWithPassword | LoginWithEmail, _) => AuthUtils.redirectToLogin() - - | (SignUP, list{"register", ..._}) => () // to prevent duplicate push - | (SignUP, _) => GlobalVars.appendDashboardPath(~url="/register")->RescriptReactRouter.push - - | (ForgetPassword | ForgetPasswordEmailSent, list{"forget-password", ..._}) => () // to prevent duplicate push - | (ForgetPassword | ForgetPasswordEmailSent, _) => - GlobalVars.appendDashboardPath(~url="/forget-password")->RescriptReactRouter.push - - | (ResendVerifyEmail | ResendVerifyEmailSent, list{"resend-mail", ..._}) => () // to prevent duplicate push - | (ResendVerifyEmail | ResendVerifyEmailSent, _) => - GlobalVars.appendDashboardPath(~url="/resend-mail")->RescriptReactRouter.push - - | _ => () - } - None - }, [authType]) - switch authType { - | EmailVerify | MagicLinkVerify => - | ActivateFromEmail => - | _ => - } -} diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicAuthTypes.res b/src/entryPoints/AuthModule/BasicAuth/BasicAuthTypes.res deleted file mode 100644 index cc5584258..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicAuthTypes.res +++ /dev/null @@ -1,12 +0,0 @@ -type basicAuthInfo = { - token: option, - merchant_id: option, - name: option, - email: option, - flow_type: option, - user_role: option, - verification_days_left: option, - merchants: option>, -} - -type flowType = MERCHANT_SELECT | DASHBOARD_ENTRY | ERROR diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicAuthUtils.res b/src/entryPoints/AuthModule/BasicAuth/BasicAuthUtils.res deleted file mode 100644 index 8ea33246b..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicAuthUtils.res +++ /dev/null @@ -1,85 +0,0 @@ -open BasicAuthTypes -open LogicUtils -let flowTypeStrToVariantMapper = val => { - switch val { - | Some("merchant_select") => MERCHANT_SELECT - | Some("dashboard_entry") => DASHBOARD_ENTRY - | Some(_) => DASHBOARD_ENTRY - | None => DASHBOARD_ENTRY - } -} - -let getBasicAuthInfo = json => { - let dict = json->JsonFlattenUtils.flattenObject(false) - let authInfo = { - email: getOptionString(dict, "email"), - flow_type: getOptionString(dict, "flow_type"), - merchant_id: getOptionString(dict, "merchant_id"), - name: getOptionString(dict, "name"), - token: getOptionString(dict, "token"), - user_role: getOptionString(dict, "user_role"), - verification_days_left: getOptionBool(dict, "verification_days_left"), - merchants: getOptionalArrayFromDict(dict, "merchants"), - } - authInfo -} - -let setBasicAuthResToStorage = json => { - LocalStorage.setItem("USER_INFO", json->JSON.stringifyAny->Option.getOr("")) -} - -let getBasicAuthInfoFromStrorage = () => { - let json = LocalStorage.getItem("USER_INFO")->getValFromNullableValue("")->safeParse - json->getBasicAuthInfo -} - -let validateForm = (values: JSON.t, keys: array) => { - let valuesDict = values->LogicUtils.getDictFromJsonObject - - let errors = Dict.make() - keys->Array.forEach(key => { - let value = LogicUtils.getString(valuesDict, key, "") - - // empty check - if value->LogicUtils.isEmptyString { - switch key { - | "email" => Dict.set(errors, key, "Please enter your Email ID"->JSON.Encode.string) - | "password" => Dict.set(errors, key, "Please enter your Password"->JSON.Encode.string) - | "create_password" => Dict.set(errors, key, "Please enter your Password"->JSON.Encode.string) - | "comfirm_password" => - Dict.set(errors, key, "Please enter your Password Once Again"->JSON.Encode.string) - | _ => - Dict.set( - errors, - key, - `${key->LogicUtils.capitalizeString} cannot be empty`->JSON.Encode.string, - ) - } - } - - // email check - if ( - value->LogicUtils.isNonEmptyString && key === "email" && value->CommonAuthUtils.isValidEmail - ) { - Dict.set(errors, key, "Please enter valid Email ID"->JSON.Encode.string) - } - - // password check - switch key { - | "password" => CommonAuthUtils.passwordKeyValidation(value, key, "password", errors) - | _ => CommonAuthUtils.passwordKeyValidation(value, key, "create_password", errors) - } - - // confirm password check - CommonAuthUtils.confirmPasswordCheck( - value, - key, - "comfirm_password", - "create_password", - valuesDict, - errors, - ) - }) - - errors->JSON.Encode.object -} diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicAuthWrapper.res b/src/entryPoints/AuthModule/BasicAuth/BasicAuthWrapper.res deleted file mode 100644 index c5f887430..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicAuthWrapper.res +++ /dev/null @@ -1,35 +0,0 @@ -@react.component -let make = (~children) => { - let url = RescriptReactRouter.useUrl() - let {authStatus, setAuthStatus, setAuthStateToLogout} = React.useContext( - AuthInfoProvider.authStatusContext, - ) - - React.useEffect(() => { - switch url.path { - | list{"user", "verify_email"} - | list{"user", "set_password"} - | list{"user", "accept_invite_from_email"} - | list{"user", "login"} - | list{"register"} => - setAuthStateToLogout() - | _ => { - let authInfo = BasicAuthUtils.getBasicAuthInfoFromStrorage() - switch authInfo.token { - | Some(_) => setAuthStatus(LoggedIn(BasicAuth(authInfo))) - | None => setAuthStateToLogout() - } - } - } - None - }, []) - -
- {switch authStatus { - | LoggedOut => - | PreLogin(_) - | LoggedIn(_) => children - | CheckingAuthStatus => - }} -
-} diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicDecisionScreen.res b/src/entryPoints/AuthModule/BasicAuth/BasicDecisionScreen.res deleted file mode 100644 index bea1a664e..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicDecisionScreen.res +++ /dev/null @@ -1,22 +0,0 @@ -@react.component -let make = () => { - let {authStatus, setAuthStatus} = React.useContext(AuthInfoProvider.authStatusContext) - - let flowType = switch authStatus { - | LoggedIn(info) => - switch info { - | BasicAuth(basicInfo) => basicInfo.flow_type->BasicAuthUtils.flowTypeStrToVariantMapper - | _ => DASHBOARD_ENTRY - } - | _ => ERROR - } - - let onClickErrorPageButton = () => { - setAuthStatus(LoggedOut) - } - switch flowType { - | MERCHANT_SELECT => - | DASHBOARD_ENTRY => - | ERROR => - } -} diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicEmailVerifyScreen.res b/src/entryPoints/AuthModule/BasicAuth/BasicEmailVerifyScreen.res deleted file mode 100644 index 0486ce426..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicEmailVerifyScreen.res +++ /dev/null @@ -1,47 +0,0 @@ -@react.component -let make = (~setAuthType) => { - open AuthProviderTypes - open APIUtils - open LogicUtils - let {setAuthStatus} = React.useContext(AuthInfoProvider.authStatusContext) - let getURL = useGetURL() - - let url = RescriptReactRouter.useUrl() - let updateDetails = useUpdateMethod() - let (errorMessage, setErrorMessage) = React.useState(_ => "") - let {setIsSidebarDetails} = React.useContext(SidebarProvider.defaultContext) - let emailVerifyUpdate = async body => { - try { - let url = getURL(~entityName=USERS, ~methodType=Post, ~userType={#VERIFY_EMAILV2}) - let res = await updateDetails(url, body, Post) - await HyperSwitchUtils.delay(1000) - setAuthStatus(LoggedIn(BasicAuth(res->BasicAuthUtils.getBasicAuthInfo))) - setIsSidebarDetails("isPinned", false->JSON.Encode.bool) - } catch { - | Exn.Error(e) => { - let err = Exn.message(e)->Option.getOr("Verification Failed") - setErrorMessage(_ => err) - setAuthStatus(LoggedOut) - } - } - } - - React.useEffect(() => { - open CommonAuthUtils - let tokenFromUrl = url.search->getDictFromUrlSearchParams->Dict.get("token") - - switch tokenFromUrl { - | Some(token) => token->generateBodyForEmailRedirection->emailVerifyUpdate->ignore - | None => setErrorMessage(_ => "Token not received") - } - None - }, []) - let onClick = () => { - AuthUtils.redirectToLogin() - setAuthType(_ => CommonAuthTypes.LoginWithEmail) - } - - -} diff --git a/src/entryPoints/AuthModule/BasicAuth/BasicInviteFromEmail.res b/src/entryPoints/AuthModule/BasicAuth/BasicInviteFromEmail.res deleted file mode 100644 index 75ae6c32e..000000000 --- a/src/entryPoints/AuthModule/BasicAuth/BasicInviteFromEmail.res +++ /dev/null @@ -1,50 +0,0 @@ -@react.component -let make = (~setAuthType) => { - open APIUtils - open LogicUtils - open AuthProviderTypes - let {setAuthStatus} = React.useContext(AuthInfoProvider.authStatusContext) - let getURL = useGetURL() - - let url = RescriptReactRouter.useUrl() - let updateDetails = useUpdateMethod() - let (errorMessage, setErrorMessage) = React.useState(_ => "") - let {setIsSidebarDetails} = React.useContext(SidebarProvider.defaultContext) - - let acceptInviteFormEmail = async body => { - try { - let url = getURL(~entityName=USERS, ~methodType=Post, ~userType=#ACCEPT_INVITE_FROM_EMAIL) - let res = await updateDetails(url, body, Post) - setAuthStatus(LoggedIn(BasicAuth(res->BasicAuthUtils.getBasicAuthInfo))) - setIsSidebarDetails("isPinned", false->JSON.Encode.bool) - } catch { - | Exn.Error(e) => { - let err = Exn.message(e)->Option.getOr("Verification Failed") - setErrorMessage(_ => err) - setAuthStatus(LoggedOut) - } - } - } - - React.useEffect(() => { - open CommonAuthUtils - let tokenFromUrl = url.search->getDictFromUrlSearchParams->Dict.get("token") - - switch tokenFromUrl { - | Some(token) => token->generateBodyForEmailRedirection->acceptInviteFormEmail->ignore - | None => setErrorMessage(_ => "Token not received") - } - - None - }, []) - let onClick = () => { - setAuthType(_ => CommonAuthTypes.LoginWithEmail) - setAuthStatus(LoggedOut) - } - - -} diff --git a/src/entryPoints/AuthModule/Common/CommonAuthHooks.res b/src/entryPoints/AuthModule/Common/CommonAuthHooks.res index 65544f208..6b081934a 100644 --- a/src/entryPoints/AuthModule/Common/CommonAuthHooks.res +++ b/src/entryPoints/AuthModule/Common/CommonAuthHooks.res @@ -72,14 +72,6 @@ let useCommonAuthInfo = () => { let authInfo: option = switch authStatus { | LoggedIn(info) => switch info { - | BasicAuth({token, merchant_id, name, email, user_role}) => - Some({ - token: token->Option.getOr("")->LogicUtils.getNonEmptyString, - merchantId: merchant_id->Option.getOr(""), - name: name->Option.getOr(""), - email: email->Option.getOr(""), - userRole: user_role->Option.getOr(""), - }) | Auth({token}) => Some({ token, diff --git a/src/entryPoints/AuthModule/PreLoginModule/AcceptInviteScreen.res b/src/entryPoints/AuthModule/PreLoginModule/AcceptInviteScreen.res index e7459a86a..7b55f5e98 100644 --- a/src/entryPoints/AuthModule/PreLoginModule/AcceptInviteScreen.res +++ b/src/entryPoints/AuthModule/PreLoginModule/AcceptInviteScreen.res @@ -12,11 +12,7 @@ let make = (~onClick) => { try { open AuthUtils - let url = getURL( - ~entityName=USERS, - ~methodType=Post, - ~userType={#ACCEPT_INVITE_FROM_EMAIL_TOKEN_ONLY}, - ) + let url = getURL(~entityName=USERS, ~methodType=Post, ~userType={#ACCEPT_INVITE_FROM_EMAIL}) let res = await updateDetails(url, body, Post) setAuthStatus(PreLogin(getPreLoginInfo(res))) } catch { diff --git a/src/entryPoints/AuthModule/PreLoginModule/MerchantSelectScreen.res b/src/entryPoints/AuthModule/PreLoginModule/MerchantSelectScreen.res index b7c3eadc8..abb720c97 100644 --- a/src/entryPoints/AuthModule/PreLoginModule/MerchantSelectScreen.res +++ b/src/entryPoints/AuthModule/PreLoginModule/MerchantSelectScreen.res @@ -27,7 +27,7 @@ let make = () => { let onClickLoginToDashboard = async () => { open AuthUtils try { - let url = getURL(~entityName=USERS, ~userType=#ACCEPT_INVITE_TOKEN_ONLY, ~methodType=Post) + let url = getURL(~entityName=USERS, ~userType=#ACCEPT_INVITE, ~methodType=Post) let acceptedMerchantIds = merchantData->Array.reduce([], (acc, ele) => { let merchantDataDict = ele->getDictFromJsonObject diff --git a/src/entryPoints/AuthModule/PreLoginModule/ResetPassword.res b/src/entryPoints/AuthModule/PreLoginModule/ResetPassword.res index 58cb4ddb6..a48fd15f2 100644 --- a/src/entryPoints/AuthModule/PreLoginModule/ResetPassword.res +++ b/src/entryPoints/AuthModule/PreLoginModule/ResetPassword.res @@ -16,7 +16,7 @@ let make = (~flowType) => { let setResetPassword = async body => { try { - let url = getURL(~entityName=USERS, ~userType=#RESET_PASSWORD_TOKEN_ONLY, ~methodType=Post) + let url = getURL(~entityName=USERS, ~userType=#RESET_PASSWORD, ~methodType=Post) let _ = await updateDetails(url, body, Post) showToast(~message=`Password Changed Successfully`, ~toastType=ToastSuccess) setAuthStatus(LoggedOut) diff --git a/src/entryPoints/AuthModule/PreLoginModule/VerifyUserFromEmail.res b/src/entryPoints/AuthModule/PreLoginModule/VerifyUserFromEmail.res index 18d9bb0c8..99ed6f158 100644 --- a/src/entryPoints/AuthModule/PreLoginModule/VerifyUserFromEmail.res +++ b/src/entryPoints/AuthModule/PreLoginModule/VerifyUserFromEmail.res @@ -14,7 +14,7 @@ let make = (~onClick) => { open CommonAuthUtils open AuthUtils let body = token->generateBodyForEmailRedirection - let url = getURL(~entityName=USERS, ~methodType=Post, ~userType={#VERIFY_EMAILV2_TOKEN_ONLY}) + let url = getURL(~entityName=USERS, ~methodType=Post, ~userType={#VERIFY_EMAILV2}) let res = await updateDetails(url, body, Post) setAuthStatus(PreLogin(getPreLoginInfo(res))) } catch { diff --git a/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res b/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res index 550bde73d..b5d966e58 100644 --- a/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res +++ b/src/entryPoints/AuthModule/TwoFaAuth/TwoFaAuth.res @@ -40,7 +40,6 @@ let make = (~setAuthStatus, ~authType, ~setAuthType) => { | _ => "Register failed, Try again" } } - Js.log2(domain, "domain") let getUserWithEmail = async body => { try { let url = getURL( @@ -158,7 +157,7 @@ let make = (~setAuthStatus, ~authType, ~setAuthType) => { | (PASSWORD, true, _, SignUP) => { let password = getString(valuesDict, "password", "") let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, #SIGNUP_TOKEN_ONLY) + getUserWithEmailPassword(body, #SIGNUP) } | (_, _, true, LoginWithEmail) => { @@ -169,7 +168,7 @@ let make = (~setAuthStatus, ~authType, ~setAuthType) => { | (_, _, _, LoginWithPassword) => { let password = getString(valuesDict, "password", "") let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, #SIGNINV2_TOKEN_ONLY) + getUserWithEmailPassword(body, #SIGNINV2) } | (_, _, _, ResendVerifyEmail) => { let exists = checkAuthMethodExists([PASSWORD]) diff --git a/src/entryPoints/FeatureFlagUtils.res b/src/entryPoints/FeatureFlagUtils.res index 887bc7960..d1b08e406 100644 --- a/src/entryPoints/FeatureFlagUtils.res +++ b/src/entryPoints/FeatureFlagUtils.res @@ -25,7 +25,6 @@ type featureFlag = { disputeAnalytics: bool, configurePmts: bool, branding: bool, - totp: bool, liveUsersCounter: bool, granularity: bool, customWebhookHeaders: bool, @@ -65,7 +64,6 @@ let featureFlagType = (featureFlags: JSON.t) => { disputeAnalytics: dict->getBool("dispute_analytics", false), configurePmts: dict->getBool("configure_pmts", false), branding: dict->getBool("branding", false), - totp: dict->getBool("totp", false), liveUsersCounter: dict->getBool("live_users_counter", false), granularity: dict->getBool("granularity", false), customWebhookHeaders: dict->getBool("custom_webhook_headers", false), diff --git a/src/entryPoints/HyperSwitchApp.res b/src/entryPoints/HyperSwitchApp.res index 37f62061f..190317d59 100644 --- a/src/entryPoints/HyperSwitchApp.res +++ b/src/entryPoints/HyperSwitchApp.res @@ -154,9 +154,7 @@ let make = () => { userRole={userRole} isAddMerchantEnabled={userRole === "org_admin" ? true : false} /> - +
{ entityName="profile setting" remainingPath renderList={() => } - renderShow={_value => - - - } + renderShow={_value => } /> | list{"quick-start"} => determineQuickStartPageState() | list{"woocommerce"} => determineWooCommerce() diff --git a/src/entryPoints/HyperSwitchEntry.res b/src/entryPoints/HyperSwitchEntry.res index 5df42e755..39b6644c5 100644 --- a/src/entryPoints/HyperSwitchEntry.res +++ b/src/entryPoints/HyperSwitchEntry.res @@ -121,11 +121,7 @@ module HyperSwitchEntryComponent = { sectionHeight="h-screen" customUI={}>
- {if featureFlagDetails.totp { - - } else { - - }} +
} diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res index 360bd2b82..85fd90832 100644 --- a/src/hooks/AuthHooks.res +++ b/src/hooks/AuthHooks.res @@ -53,7 +53,7 @@ let useApiFetcher = () => { | PreLogin(info) => info.token | LoggedIn(info) => switch info { - | BasicAuth(_) | Auth(_) => AuthUtils.getUserInfoDetailsFromLocalStorage().token + | Auth(_) => AuthUtils.getUserInfoDetailsFromLocalStorage().token } | _ => None } diff --git a/src/screens/APIUtils/APIUtils.res b/src/screens/APIUtils/APIUtils.res index 1b76cb544..b6ad74d78 100644 --- a/src/screens/APIUtils/APIUtils.res +++ b/src/screens/APIUtils/APIUtils.res @@ -383,7 +383,6 @@ let useGetURL = () => { | None => `${userUrl}/connect_account` } | #SIGNINV2 => `${userUrl}/v2/signin` - | #SIGNINV2_TOKEN_ONLY => `${userUrl}/v2/signin?token_only=true` | #CHANGE_PASSWORD => `${userUrl}/change_password` | #SIGNUP | #SIGNOUT @@ -395,8 +394,6 @@ let useGetURL = () => { | Some(params) => `${userUrl}/${(userType :> string)->String.toLowerCase}?${params}` | None => `${userUrl}/${(userType :> string)->String.toLowerCase}` } - | #SIGNUP_TOKEN_ONLY => `${userUrl}/signup?token_only=true` - | #RESET_PASSWORD_TOKEN_ONLY => `${userUrl}/reset_password?token_only=true` // POST LOGIN QUESTIONARE | #SET_METADATA => @@ -438,11 +435,6 @@ let useGetURL = () => { | Some(params) => `${userUrl}/user/${(userType :> string)->String.toLowerCase}?${params}` | None => `${userUrl}/user/${(userType :> string)->String.toLowerCase}` } - | #INVITE_MULTIPLE_TOKEN_ONLY => - switch queryParamerters { - | Some(params) => `${userUrl}/user/invite_multiple?${params}&token_only=true` - | None => `${userUrl}/user/invite_multiple?token_only=true` - } // SWITCH & CREATE MERCHANT | #SWITCH_MERCHANT => @@ -478,7 +470,6 @@ let useGetURL = () => { } // SPT FLOWS (Merchant select) - | #ACCEPT_INVITE_TOKEN_ONLY => `${userUrl}/user/invite/accept?token_only=true` | #MERCHANTS_SELECT => `${userUrl}/merchants_select/list` // SPT FLOWS (Totp) @@ -504,11 +495,6 @@ let useGetURL = () => { | #SIGN_IN_WITH_SSO => `${userUrl}/oidc` | #AUTH_SELECT => `${userUrl}/auth/select` - // SPT EMAIL FLOWS - | #VERIFY_EMAILV2_TOKEN_ONLY => `${userUrl}/v2/verify_email?token_only=true` - | #ACCEPT_INVITE_FROM_EMAIL_TOKEN_ONLY => - `${userUrl}/accept_invite_from_email?token_only=true` - | #NONE => "" } diff --git a/src/screens/APIUtils/APIUtilsTypes.res b/src/screens/APIUtils/APIUtilsTypes.res index 04858cadd..c3fb7f315 100644 --- a/src/screens/APIUtils/APIUtilsTypes.res +++ b/src/screens/APIUtils/APIUtilsTypes.res @@ -61,7 +61,6 @@ type userType = [ | #SIGNOUT | #FORGOT_PASSWORD | #RESET_PASSWORD - | #RESET_PASSWORD_TOKEN_ONLY | #VERIFY_EMAIL_REQUEST | #VERIFY_EMAILV2 | #ACCEPT_INVITE_FROM_EMAIL @@ -75,17 +74,11 @@ type userType = [ | #USER_UPDATE | #UPDATE_ROLE | #INVITE_MULTIPLE - | #INVITE_MULTIPLE_TOKEN_ONLY | #RESEND_INVITE | #CREATE_MERCHANT | #ACCEPT_INVITE - | #ACCEPT_INVITE_TOKEN_ONLY | #GET_PERMISSIONS | #CREATE_CUSTOM_ROLE - | #SIGNUP_TOKEN_ONLY - | #SIGNINV2_TOKEN_ONLY - | #VERIFY_EMAILV2_TOKEN_ONLY - | #ACCEPT_INVITE_FROM_EMAIL_TOKEN_ONLY | #FROM_EMAIL | #USER_INFO | #ROTATE_PASSWORD diff --git a/src/screens/Home/Home.res b/src/screens/Home/Home.res index 6c194a402..8d6efdb08 100644 --- a/src/screens/Home/Home.res +++ b/src/screens/Home/Home.res @@ -3,14 +3,13 @@ let make = () => { open HomeUtils open PageUtils let greeting = getGreeting() - let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom + let {userInfo: {recoveryCodesLeft}} = React.useContext(UserInfoProvider.defaultContext) let recoveryCode = recoveryCodesLeft->Option.getOr(0)
- Option.isSome && recoveryCode < 3}> + Option.isSome && recoveryCode < 3}> diff --git a/src/screens/Home/HomeV2.res b/src/screens/Home/HomeV2.res index 8e464785c..fd5a03008 100644 --- a/src/screens/Home/HomeV2.res +++ b/src/screens/Home/HomeV2.res @@ -409,15 +409,13 @@ let make = () => { let {isProdIntentCompleted} = React.useContext(GlobalProvider.defaultContext) let enumDetails = Recoil.useRecoilValueFromAtom(HyperswitchAtom.enumVariantAtom) let typedEnumValue = enumDetails->LogicUtils.safeParse->QuickStartUtils.getTypedValueFromDict - let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom let {userInfo: {recoveryCodesLeft}} = React.useContext(UserInfoProvider.defaultContext) let recoveryCode = recoveryCodesLeft->Option.getOr(0)
- Option.isSome && recoveryCode < 3}> + Option.isSome && recoveryCode < 3}> diff --git a/src/screens/Settings/BusinessMapping/BusinessProfile.res b/src/screens/Settings/BusinessMapping/BusinessProfile.res index d7dabc862..67715712c 100644 --- a/src/screens/Settings/BusinessMapping/BusinessProfile.res +++ b/src/screens/Settings/BusinessMapping/BusinessProfile.res @@ -195,8 +195,7 @@ let make = ( setOffset currrentFetchCount={businessProfileValues->Array.length} /> - +
{ - let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - let {userInfo: {isTwoFactorAuthSetup}} = React.useContext(UserInfoProvider.defaultContext)
@@ -206,7 +204,7 @@ let make = () => {
- +
diff --git a/src/screens/Sidebar/Sidebar.res b/src/screens/Sidebar/Sidebar.res index 95d14b284..3c729500f 100644 --- a/src/screens/Sidebar/Sidebar.res +++ b/src/screens/Sidebar/Sidebar.res @@ -616,7 +616,7 @@ let make = (
- +
{ open APIUtils let getURL = useGetURL() - let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom let {setAuthStatus, authStatus} = React.useContext(AuthInfoProvider.authStatusContext) let {userInfo: {merchantId}} = React.useContext(UserInfoProvider.defaultContext) let (value, setValue) = React.useState(() => "") let merchantId = switch authStatus { | LoggedIn(info) => switch info { - | BasicAuth(basicInfo) => basicInfo.merchant_id->Option.getOr("") | Auth(_) => merchantId } | _ => "" @@ -293,18 +291,15 @@ let make = (~userRole, ~isAddMerchantEnabled=false) => { let res = await updateDetails(url, body->JSON.Encode.object, Post) // TODO: When BE changes the response of this api re-evaluate the below conditions - if featureFlagDetails.totp { - let responseDict = res->getDictFromJsonObject - // Need to revert back once backend does the changes - let role_id = responseDict->getString("user_role", "") - responseDict->Dict.set("role_id", role_id->JSON.Encode.string) - // + let responseDict = res->getDictFromJsonObject - setAuthStatus(LoggedIn(Auth(AuthUtils.getAuthInfo(responseDict->JSON.Encode.object)))) - } else { - setAuthStatus(LoggedIn(BasicAuth(res->BasicAuthUtils.getBasicAuthInfo))) - } + // Need to revert back once backend does the changes + let role_id = responseDict->getString("user_role", "") + responseDict->Dict.set("role_id", role_id->JSON.Encode.string) + // + + setAuthStatus(LoggedIn(Auth(AuthUtils.getAuthInfo(responseDict->JSON.Encode.object)))) setSuccessModal(_ => true) await HyperSwitchUtils.delay(2000) diff --git a/src/screens/UserManagement/OldUserManagement/InviteUsers.res b/src/screens/UserManagement/OldUserManagement/InviteUsers.res index 17758d13d..22e90f1bf 100644 --- a/src/screens/UserManagement/OldUserManagement/InviteUsers.res +++ b/src/screens/UserManagement/OldUserManagement/InviteUsers.res @@ -101,7 +101,7 @@ let make = (~isInviteUserFlow=true, ~setNewRoleSelected=_ => (), ~currentRole=?) | None => "merchant_view_only" } - let {email, totp} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom + let {email} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom let {permissionInfo, setPermissionInfo} = React.useContext(GlobalProvider.defaultContext) let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let (roleTypeValue, setRoleTypeValue) = React.useState(_ => defaultRole) @@ -116,21 +116,12 @@ let make = (~isInviteUserFlow=true, ~setNewRoleSelected=_ => (), ~currentRole=?) }, []) let getURLForInviteMultipleUser = { - if totp { - getURL( - ~entityName=USERS, - ~userType=#INVITE_MULTIPLE_TOKEN_ONLY, - ~methodType=Post, - ~queryParamerters=Some(`auth_id=${authId}`), - ) - } else { - getURL( - ~entityName=USERS, - ~userType=#INVITE_MULTIPLE, - ~methodType=Post, - ~queryParamerters=Some(`auth_id=${authId}`), - ) - } + getURL( + ~entityName=USERS, + ~userType=#INVITE_MULTIPLE, + ~methodType=Post, + ~queryParamerters=Some(`auth_id=${authId}`), + ) } let inviteListOfUsersWithInviteMultiple = async values => {