fix(#2227): send url params post

keep-around/78728aaea3c73604b730226a5c18add5a7bcecd6
Andrei Dekterev 4 years ago
parent f9231cd90a
commit 09b701035f
  1. 3
      src/features/AuthServiceApp/components/Registration/hooks.tsx
  2. 22
      src/features/AuthServiceApp/requests/register.tsx

@ -1,6 +1,7 @@
import { SyntheticEvent, useState } from 'react' import { SyntheticEvent, useState } from 'react'
import { useAuthFields } from 'features/AuthServiceApp/hooks/useAuthFields' import { useAuthFields } from 'features/AuthServiceApp/hooks/useAuthFields'
import { useLexicsStore } from 'features/LexicsStore'
import { registerCheck } from '../../requests/register' import { registerCheck } from '../../requests/register'
@ -26,6 +27,7 @@ export const useRegistrationForm = () => {
|| Boolean(formError) || Boolean(formError)
|| isFetching || isFetching
) )
const { lang } = useLexicsStore()
const handleSubmit = async (event: SyntheticEvent) => { const handleSubmit = async (event: SyntheticEvent) => {
event?.preventDefault() event?.preventDefault()
@ -33,6 +35,7 @@ export const useRegistrationForm = () => {
try { try {
await registerCheck({ await registerCheck({
email, email,
lang,
password, password,
}) })
setAuthError('') setAuthError('')

@ -1,5 +1,7 @@
import { getApiUrl } from 'features/AuthServiceApp/config/routes' import { getApiUrl } from 'features/AuthServiceApp/config/routes'
import { getClientSettings } from 'features/AuthStore/helpers'
const errorLexics = { const errorLexics = {
1: 'error_invalid_email_or_password', 1: 'error_invalid_email_or_password',
2: 'error_missing_required_argument', 2: 'error_missing_required_argument',
@ -23,19 +25,39 @@ type SuccessResponse = {
type RegisterProps = { type RegisterProps = {
email: string, email: string,
lang?: string,
password: string, password: string,
} }
export const registerCheck = async ({ export const registerCheck = async ({
email, email,
lang,
password, password,
} : RegisterProps) => { } : RegisterProps) => {
const {
client_id,
redirect_uri,
response_mode,
response_type,
scope,
} = getClientSettings()
const url = getApiUrl('/registration') const url = getApiUrl('/registration')
const paramsUrl = {
client_id: client_id || 'ott-web',
lang: lang || 'en',
redirect_uri: redirect_uri || 'http://instat.tv/redirect',
response_mode: response_mode || 'query',
response_type: response_type || 'id_token token',
scope: scope || 'openid',
}
const init: RequestInit = { const init: RequestInit = {
body: new URLSearchParams({ body: new URLSearchParams({
email, email,
password, password,
...paramsUrl,
}), }),
method: 'POST', method: 'POST',
} }

Loading…
Cancel
Save