📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
sending credentials to server
Blue Mouse598fb18a3d6c
diff --git a/src/api/index.ts b/src/api/index.tsindex b7ac8d434..27b40b708 100644--- a/src/api/index.ts+++ b/src/api/index.ts@@ -808,3 +808,14 @@ export const confirmTransferProject = (uuid: string) =>? error.response.data: error.response.data.message})++export const googleAuth = (data: any) =>+ api+ .post('google-auth', data)+ .then((response): unknown => response.data)+ .catch((error) => {+ debug('%s', error)+ throw _isEmpty(error.response.data?.message)+ ? error.response.data+ : error.response.data.message+ })diff --git a/src/components/GoogleAuth.tsx b/src/components/GoogleAuth.tsxindex 799face70..82d74f9d5 100644--- a/src/components/GoogleAuth.tsx+++ b/src/components/GoogleAuth.tsx@@ -1,6 +1,7 @@import React, { useEffect, useRef } from 'react'import { useTranslation } from 'react-i18next'+import { googleAuth } from 'api'import Button from 'ui/Button'import GoogleGSVG from 'ui/icons/GoogleG'@@ -19,19 +20,19 @@ const loadScript = (src: string): Promise<any> => new Promise((resolve, reject)document.body.appendChild(script)})-const GoogleAuth = () => {+interface IGoogleAuth {+ setIsLoading: (isLoading: boolean) => void,+}++const GoogleAuth: React.FC<IGoogleAuth> = ({ setIsLoading }) => {const { t } = useTranslation()const actualGoogleButton = useRef(null)- // useEffect(() => {- // if (actualGoogleButton.current) {- // // @ts-ignore- // actualGoogleButton.current.click()- // }- // }, [actualGoogleButton.current])+ const handleCredentialResponse = async (response: any) => {+ const result = await googleAuth({ token: response.credential })+ console.log(result) // should be { user, access_token, refresh_token }- const handleCredentialResponse = (response: any) => {- console.log(response)+ setIsLoading(false)}const renderGoogleLoginButton = async () => {@@ -65,6 +66,7 @@ const GoogleAuth = () => {}const googleLogin = async () => {+ setIsLoading(true)await renderGoogleLoginButton()clickGoogleLoginButton()}diff --git a/src/pages/Auth/Signup/Signup.tsx b/src/pages/Auth/Signup/Signup.tsxindex d70f8ccb1..cd00b13c6 100644--- a/src/pages/Auth/Signup/Signup.tsx+++ b/src/pages/Auth/Signup/Signup.tsx@@ -250,7 +250,7 @@ const Signup = ({ signup }: {{t('auth.signup.button')}</Button></div>- <GoogleAuth />+ <GoogleAuth setIsLoading={setIsLoading} /></form></div></Title>