Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
fix: passowrd changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aswathy-deriv committed Feb 20, 2024
1 parent 99d00ec commit 3f73ee4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
23 changes: 14 additions & 9 deletions src/features/pages/signup-academy-complete/password-form.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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;
`
Expand All @@ -38,14 +38,22 @@ 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', {
new_account_virtual: 1,
type: 'trading',
client_password: password,
residence: residence,
verification_code: 'uoJvVuQ6',
verification_code: codeValue,
})
.then((response) => {
console.log(response)
Expand All @@ -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()
}
})
}
Expand All @@ -69,7 +74,7 @@ const AcademyPasswordForm = ({ residence }: AcademyPasswordFormProps) => {
</Typography.Paragraph>

<Flex.Item>
<AcademyInput
<AcademyPasswordInput
id="dm-password"
name="password"
type="password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import { localize } from 'components/localization'

export const password_regex_validate = {
password: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()\-_=+[{\]};:'",<.>/?]).{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

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_`,
Expand Down

0 comments on commit 3f73ee4

Please sign in to comment.