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 a-stage: build
rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/a-wwwroot/ rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/a-wwwroot/
b-stage: build b-stage: build_auth
rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/b-wwwroot/ 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 c-stage: build
rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/c-wwwroot/ 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, SyntheticEvent,
useState, useState,
} from 'react' } from 'react'
import { useLocation } from 'react-router-dom'
import { useAuthFields } from 'features/AuthServiceApp/hooks/useAuthFields' import { useAuthFields } from 'features/AuthServiceApp/hooks/useAuthFields'
import { changePassword } from 'features/AuthServiceApp/requests/changePassword' import { changePassword } from 'features/AuthServiceApp/requests/changePassword'
@ -18,20 +17,11 @@ export const useChangePasswordForm = () => {
checkPassword, checkPassword,
} = useAuthFields('login') } = 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) => { const handleSubmit = async (event: SyntheticEvent) => {
event?.preventDefault() event?.preventDefault()
setIsFetching(true) setIsFetching(true)
try { try {
const redirectUrl = await changePassword(password, token || '') const redirectUrl = await changePassword(password)
setError('') setError('')
setIsFetching(false) setIsFetching(false)
if (redirectUrl) { if (redirectUrl) {

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

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

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

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

Loading…
Cancel
Save