feat(#2199): fix url with token

keep-around/11ba998252d14e10552e3bffcce91ab0afdc9329
Andrei Dekterev 4 years ago
parent e644249193
commit aba9baa5db
  1. 4
      Makefile
  2. 12
      src/features/AuthServiceApp/components/ChangePassword/hooks.tsx
  3. 7
      src/features/AuthServiceApp/components/ChangePassword/index.tsx
  4. 1
      src/features/AuthServiceApp/components/RecoveryPopup/hooks.tsx
  5. 3
      src/features/AuthServiceApp/components/RecoveryPopup/index.tsx
  6. 8
      src/features/AuthServiceApp/requests/changePassword.tsx

@ -84,8 +84,8 @@ stage: build
a-stage: build
rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/a-wwwroot/
b-stage: build
rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/b-wwwroot/
b-stage: build_auth
rsync -zavP --delete-before build_auth/ -e 'ssh -p 666' ott-staging@10.0.3.8:/usr/local/www/ott-staging/b-wwwroot/
c-stage: build
rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/c-wwwroot/

@ -3,7 +3,6 @@ import {
SyntheticEvent,
useState,
} from 'react'
import { useLocation } from 'react-router-dom'
import { useAuthFields } from 'features/AuthServiceApp/hooks/useAuthFields'
import { changePassword } from 'features/AuthServiceApp/requests/changePassword'
@ -18,20 +17,11 @@ export const useChangePasswordForm = () => {
checkPassword,
} = useAuthFields('login')
const { search } = useLocation()
const getUrlParam = (key: string) => {
const token = new URLSearchParams(search).get(key)
return token
}
const token = getUrlParam('token')
const handleSubmit = async (event: SyntheticEvent) => {
event?.preventDefault()
setIsFetching(true)
try {
const redirectUrl = await changePassword(password, token || '')
const redirectUrl = await changePassword(password)
setError('')
setIsFetching(false)
if (redirectUrl) {

@ -19,11 +19,9 @@ const ChangePassword = () => {
const {
confirmPassword,
error,
// formError,
handleSubmit,
isFetching,
isSubmitDisabled,
// onPasswordBlur,
onConfirmPasswordChange,
onPasswordChange,
password,
@ -33,9 +31,6 @@ const ChangePassword = () => {
<CenterBlock>
<Logo />
<Form
// method='PUT'
// // ref={formRef}
// // action={url}
onSubmit={handleSubmit}
>
<BlockTitle t='set_new_password' />
@ -50,7 +45,6 @@ const ChangePassword = () => {
placeholderLexic='password_new'
value={password}
onChange={onPasswordChange}
// onBlur={onPasswordBlur}
/>
<PasswordInput
type='password'
@ -59,7 +53,6 @@ const ChangePassword = () => {
placeholderLexic='password_repeat'
value={confirmPassword}
onChange={onConfirmPasswordChange}
// onBlur={onPasswordBlur}
/>
</InputGroup>
<Error>

@ -56,7 +56,6 @@ export const useRecovery = (setIsModalOpen: (value: boolean) => void) => {
isFetching,
isSendBtnDisabled,
isSendMessage,
// onEmailBlur,
onEmailChange,
}
}

@ -17,7 +17,6 @@ import {
} from './styled'
import { Input } from '../Input'
// import { Error } from '../../styled'
import { InputGroup, Error } from '../../styled'
type Props = {
@ -31,7 +30,6 @@ export const RecoveryPopup = (props: Props) => {
const {
closePopup,
error,
// onEmailBlur,
handleSubmit,
isFetching,
isSendBtnDisabled,
@ -66,7 +64,6 @@ export const RecoveryPopup = (props: Props) => {
autoComplete='email'
placeholderLexic='registration_email'
onChange={onEmailChange}
// onBlur={onEmailBlur}
/>
</InputGroup>
<Error>

@ -1,8 +1,8 @@
import { getApiUrl } from '../config/routes'
const errorLexics = {
1: 'error_зassword mismatch',
4: 'error_user_not_found',
5: '',
10: '',
}
type FailedResponse = {
@ -20,8 +20,8 @@ type SuccessResponse = {
ok: true,
}
export const changePassword = async (password: string, token: string) => {
const url = getApiUrl(`/change_password?token=${token}`)
export const changePassword = async (password: string) => {
const url = getApiUrl('/change_password')
const init: RequestInit = {
body: new URLSearchParams({
password,

Loading…
Cancel
Save