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

@ -1,5 +1,7 @@
import { getApiUrl } from 'features/AuthServiceApp/config/routes'
import { getClientSettings } from 'features/AuthStore/helpers'
const errorLexics = {
1: 'error_invalid_email_or_password',
2: 'error_missing_required_argument',
@ -23,19 +25,39 @@ type SuccessResponse = {
type RegisterProps = {
email: string,
lang?: string,
password: string,
}
export const registerCheck = async ({
email,
lang,
password,
} : RegisterProps) => {
const {
client_id,
redirect_uri,
response_mode,
response_type,
scope,
} = getClientSettings()
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 = {
body: new URLSearchParams({
email,
password,
...paramsUrl,
}),
method: 'POST',
}

Loading…
Cancel
Save