fix(#2227): fix post params in auth

keep-around/78728aaea3c73604b730226a5c18add5a7bcecd6
Andrei Dekterev 4 years ago
parent 12dde922e1
commit 7631931f01
  1. 9
      src/features/AuthServiceApp/components/Login/hooks.tsx
  2. 5
      src/features/AuthServiceApp/components/Login/index.tsx
  3. 4
      src/features/AuthServiceApp/requests/authСheck.tsx

@ -15,6 +15,7 @@ import { useLocation } from 'react-router'
const url = getApiUrl('/authorize') const url = getApiUrl('/authorize')
export const useLoginForm = () => { export const useLoginForm = () => {
const location = useLocation()
const { lang } = useLexicsStore() const { lang } = useLexicsStore()
const [authError, setAuthError] = useState('') const [authError, setAuthError] = useState('')
const [isFetching, setIsFetching] = useState(false) const [isFetching, setIsFetching] = useState(false)
@ -43,10 +44,7 @@ export const useLoginForm = () => {
setIsModalOpen(true) setIsModalOpen(true)
} }
// const submitForm = () => formRef.current?.submit() const redirect_url = new URLSearchParams(location.search).get('redirect_uri') || ''
const location = useLocation()
const redirect_url = new URLSearchParams(location.search).get('redirect_uri')
const handleError = (error: string) => { const handleError = (error: string) => {
setAuthError(error) setAuthError(error)
@ -61,12 +59,13 @@ export const useLoginForm = () => {
email, email,
lang, lang,
password, password,
redirect_url,
) )
await (authorize( await (authorize(
email, email,
lang, lang,
password, password,
redirect_url || '', redirect_url,
)) ))
} catch (err) { } catch (err) {
handleError(String(err)) handleError(String(err))

@ -27,7 +27,6 @@ const Login = () => {
authError, authError,
email, email,
formError, formError,
formRef,
handleModalOpen, handleModalOpen,
handleSubmit, handleSubmit,
isFetching, isFetching,
@ -39,16 +38,12 @@ const Login = () => {
onPasswordChange, onPasswordChange,
password, password,
setIsModalOpen, setIsModalOpen,
url,
} = useLoginForm() } = useLoginForm()
return ( return (
<CenterBlock> <CenterBlock>
<Logo /> <Logo />
<Form <Form
method='POST'
ref={formRef}
action={url}
onSubmit={handleSubmit} onSubmit={handleSubmit}
> >
<BlockTitle t='step_title_login' /> <BlockTitle t='step_title_login' />

@ -23,10 +23,10 @@ export const loginCheck = async (
email: string, email: string,
lang: string, lang: string,
password: string, password: string,
redirect_url: string,
) => { ) => {
const { const {
client_id, client_id,
redirect_uri,
response_mode, response_mode,
response_type, response_type,
scope, scope,
@ -35,7 +35,7 @@ export const loginCheck = async (
const paramsUrl = { const paramsUrl = {
client_id, client_id,
lang, lang,
redirect_uri, redirect_uri: redirect_url,
response_mode, response_mode,
response_type, response_type,
scope, scope,

Loading…
Cancel
Save