From 3f73ee418ef08a5826ad4f1e6fcb12449e49e82c Mon Sep 17 00:00:00 2001 From: aswathy-deriv Date: Tue, 20 Feb 2024 17:34:22 +0400 Subject: [PATCH] fix: passowrd changes --- crowdin/messages.json | 1 + .../signup-academy-complete/password-form.tsx | 23 +++++++++++-------- .../password-validation.tsx | 5 ++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/crowdin/messages.json b/crowdin/messages.json index f02d3686145..bc175f8f23e 100644 --- a/crowdin/messages.json +++ b/crowdin/messages.json @@ -1488,6 +1488,7 @@ "1403586449": "Competitively tighter spreads", "1403761038": "Real account ", "1403848854": "The Deriv MT5 Standard account offers new and experienced traders high leverage and variable spreads for maximum flexibility.", + "1404440001": "Repeats like “abcabcabc” are only slightly harder to guess than “abc”.", "1404594106": "Swap short (Daily points)", "1405194573": "Locate the live chat widget on our website or app at the bottom right corner of the screen.", "1405929527": "Your IB commissions earned from Deriv X are credited directly into your Deriv account daily.", diff --git a/src/features/pages/signup-academy-complete/password-form.tsx b/src/features/pages/signup-academy-complete/password-form.tsx index 202edfac4cf..32ba1db9e85 100644 --- a/src/features/pages/signup-academy-complete/password-form.tsx +++ b/src/features/pages/signup-academy-complete/password-form.tsx @@ -1,9 +1,10 @@ -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' import styled from 'styled-components' import { navigate } from 'gatsby' import { trading_btn, signup_form_line } from './signup-academy.module.scss' -import AcademyInput from './academy-input' +import AcademyPasswordInput from './academy-input' import { academy_validation } from './password-validation' +import { isBrowser } from 'common/utility' import Flex from 'features/components/atoms/flex-box' import Typography from 'features/components/atoms/typography' import { Localize, localize } from 'components/localization' @@ -18,7 +19,6 @@ const AcademyPasswordForm = ({ residence }: AcademyPasswordFormProps) => { const [password, setPassword] = useState('') const [form_errors, setFormErrors] = useState('') const [submit_status, setSubmitStatus] = useState('') - const [submit_error_msg, setSubmitErrorMsg] = useState('') const GoTrading = styled(Button)` border-radius: 4px; ` @@ -38,6 +38,14 @@ const AcademyPasswordForm = ({ residence }: AcademyPasswordFormProps) => { setFormErrors('') } + const params = new URLSearchParams(isBrowser() && location.search) + const codeValue = params.get('code') + + const handleNavigation = () => { + window.location.href = + 'https://oauth.deriv.com/oauth2/session/thinkific/create?app_id=37228' + } + const GetDerivAcademy = () => { apiManager .augmentedSend('new_account_virtual', { @@ -45,7 +53,7 @@ const AcademyPasswordForm = ({ residence }: AcademyPasswordFormProps) => { type: 'trading', client_password: password, residence: residence, - verification_code: 'uoJvVuQ6', + verification_code: codeValue, }) .then((response) => { console.log(response) @@ -54,10 +62,7 @@ const AcademyPasswordForm = ({ residence }: AcademyPasswordFormProps) => { setSubmitErrorMsg(response.error.message) } else { setSubmitStatus('success') - navigate( - 'https://oauth.deriv.com/oauth2/session/thinkific/create?app_id=37228', - { replace: true }, - ) + handleNavigation() } }) } @@ -69,7 +74,7 @@ const AcademyPasswordForm = ({ residence }: AcademyPasswordFormProps) => { - /?]).{8,}$/, + common_password: /^(?!.*(.)\1.*\1)(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]{6,}$/, } export const validation_is_lack_number = (input, min_digit) => input.length + 1 > min_digit @@ -9,6 +10,10 @@ export const validation_is_lack_number = (input, min_digit) => input.length + 1 export const passwordValidation = (input) => { if (!input) { return localize('_t_You should enter 8-25 characters._t_') + } else if (password_regex_validate.common_password.test(input)) { + return localize( + `_t_Repeats like “abcabcabc” are only slightly harder to guess than “abc”._t_`, + ) } else if (!password_regex_validate.password.test(input)) { return localize( `_t_Password should have lower and uppercase English letters with numbers._t_`,