From a68d49fcbed798b10da4aed44b650ffe98f9c072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Fri, 3 Jan 2025 09:46:07 +0100 Subject: [PATCH] Fix Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data --- src/auth/hooks/useAuthProvider.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/auth/hooks/useAuthProvider.ts b/src/auth/hooks/useAuthProvider.ts index 30ab804c3f..93755c1446 100644 --- a/src/auth/hooks/useAuthProvider.ts +++ b/src/auth/hooks/useAuthProvider.ts @@ -173,9 +173,19 @@ export function useAuthProvider({ intl, notify, apolloClient }: UseAuthProviderO } }; const handleRequestExternalLogin = async (pluginId: string, input: RequestExternalLoginInput) => { + let stringifyInput: string; + + try { + stringifyInput = JSON.stringify(input); + } catch (error) { + setErrors(["externalLoginError"]); + + return; + } + const result = await getExternalAuthUrl({ pluginId, - input: JSON.stringify(input), + input: stringifyInput, }); return result?.data?.externalAuthenticationUrl;