diff --git a/src/features/AuthServiceApp/components/Registration/hooks.tsx b/src/features/AuthServiceApp/components/Registration/hooks.tsx index fef571be..c36e199d 100644 --- a/src/features/AuthServiceApp/components/Registration/hooks.tsx +++ b/src/features/AuthServiceApp/components/Registration/hooks.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('') diff --git a/src/features/AuthServiceApp/requests/register.tsx b/src/features/AuthServiceApp/requests/register.tsx index 6fb41a5e..12a2935b 100644 --- a/src/features/AuthServiceApp/requests/register.tsx +++ b/src/features/AuthServiceApp/requests/register.tsx @@ -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', }