diff --git a/src/features/AuthServiceApp/components/Login/hooks.tsx b/src/features/AuthServiceApp/components/Login/hooks.tsx index 49de258f..61c96d57 100644 --- a/src/features/AuthServiceApp/components/Login/hooks.tsx +++ b/src/features/AuthServiceApp/components/Login/hooks.tsx @@ -15,6 +15,7 @@ import { useLocation } from 'react-router' const url = getApiUrl('/authorize') export const useLoginForm = () => { + const location = useLocation() const { lang } = useLexicsStore() const [authError, setAuthError] = useState('') const [isFetching, setIsFetching] = useState(false) @@ -43,10 +44,7 @@ export const useLoginForm = () => { setIsModalOpen(true) } - // const submitForm = () => formRef.current?.submit() - const location = useLocation() - - const redirect_url = new URLSearchParams(location.search).get('redirect_uri') + const redirect_url = new URLSearchParams(location.search).get('redirect_uri') || '' const handleError = (error: string) => { setAuthError(error) @@ -61,12 +59,13 @@ export const useLoginForm = () => { email, lang, password, + redirect_url, ) await (authorize( email, lang, password, - redirect_url || '', + redirect_url, )) } catch (err) { handleError(String(err)) diff --git a/src/features/AuthServiceApp/components/Login/index.tsx b/src/features/AuthServiceApp/components/Login/index.tsx index 5990918a..65977ca9 100644 --- a/src/features/AuthServiceApp/components/Login/index.tsx +++ b/src/features/AuthServiceApp/components/Login/index.tsx @@ -27,7 +27,6 @@ const Login = () => { authError, email, formError, - formRef, handleModalOpen, handleSubmit, isFetching, @@ -39,16 +38,12 @@ const Login = () => { onPasswordChange, password, setIsModalOpen, - url, } = useLoginForm() return (
diff --git a/src/features/AuthServiceApp/requests/authСheck.tsx b/src/features/AuthServiceApp/requests/authСheck.tsx index a7cc24a8..218d167c 100644 --- a/src/features/AuthServiceApp/requests/authСheck.tsx +++ b/src/features/AuthServiceApp/requests/authСheck.tsx @@ -23,10 +23,10 @@ export const loginCheck = async ( email: string, lang: string, password: string, + redirect_url: string, ) => { const { client_id, - redirect_uri, response_mode, response_type, scope, @@ -35,7 +35,7 @@ export const loginCheck = async ( const paramsUrl = { client_id, lang, - redirect_uri, + redirect_uri: redirect_url, response_mode, response_type, scope,