From fcbf4f8f0688a68bb74a5c6934c80ea936cf35eb Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Thu, 6 Jun 2024 12:45:42 +0700 Subject: [PATCH] White list some non critical auth errors (#27049) --- .../interfaces/SignIn/ResetPasswordForm.tsx | 6 +++++- .../interfaces/SignIn/SignInSSOForm.tsx | 7 ++++++- .../interfaces/SignIn/SignInWithSSO.tsx | 20 ------------------- .../interfaces/SignIn/SignUpForm.tsx | 7 ++++++- apps/studio/pages/sign-in.tsx | 14 +++++++++++-- 5 files changed, 29 insertions(+), 25 deletions(-) delete mode 100644 apps/studio/components/interfaces/SignIn/SignInWithSSO.tsx diff --git a/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsx b/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsx index b02724dd9ee..9d8bae740db 100644 --- a/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsx +++ b/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsx @@ -6,6 +6,8 @@ import { auth } from 'lib/gotrue' import { passwordSchema } from 'lib/schemas' import { Button, Form, Input } from 'ui' +const WHITELIST_ERRORS = ['New password should be different from the old password'] + const ResetPasswordForm = () => { const router = useRouter() @@ -21,7 +23,9 @@ const ResetPasswordForm = () => { await router.push('/projects') } else { toast.error(`Failed to save password: ${error.message}`, { id: toastId }) - Sentry.captureMessage('[CRITICAL] Failed to reset password: ' + error.message) + if (!WHITELIST_ERRORS.includes(error.message)) { + Sentry.captureMessage('[CRITICAL] Failed to reset password: ' + error.message) + } } } diff --git a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx index 2df60abc2c6..900ce8590e3 100644 --- a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx +++ b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx @@ -9,6 +9,8 @@ import { BASE_PATH } from 'lib/constants' import { auth, buildPathWithParams } from 'lib/gotrue' import { Button, Form, Input } from 'ui' +const WHITELIST_ERRORS = ['No SSO provider assigned for this domain'] + const SignInSSOForm = () => { const queryClient = useQueryClient() const captchaRef = useRef(null) @@ -54,7 +56,10 @@ const SignInSSOForm = () => { setCaptchaToken(null) captchaRef.current?.resetCaptcha() toast.error(`Failed to sign in: ${error.message}`, { id: toastId }) - Sentry.captureMessage('[CRITICAL] Failed to sign in via SSO: ' + error.message) + + if (!WHITELIST_ERRORS.includes(error.message)) { + Sentry.captureMessage('[CRITICAL] Failed to sign in via SSO: ' + error.message) + } } } diff --git a/apps/studio/components/interfaces/SignIn/SignInWithSSO.tsx b/apps/studio/components/interfaces/SignIn/SignInWithSSO.tsx deleted file mode 100644 index 1ff6f1f13ca..00000000000 --- a/apps/studio/components/interfaces/SignIn/SignInWithSSO.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Lock } from 'lucide-react' -import Link from 'next/link' -import { Button } from 'ui' - -const SignInWithSSO = ({ searchParams }: { searchParams?: string }) => { - return ( - - ) -} - -export default SignInWithSSO diff --git a/apps/studio/components/interfaces/SignIn/SignUpForm.tsx b/apps/studio/components/interfaces/SignIn/SignUpForm.tsx index 53af5276d50..73c4b27475c 100644 --- a/apps/studio/components/interfaces/SignIn/SignUpForm.tsx +++ b/apps/studio/components/interfaces/SignIn/SignUpForm.tsx @@ -20,6 +20,8 @@ import { } from 'ui' import PasswordConditionsHelper from './PasswordConditionsHelper' +const WHITELIST_ERRORS = ['A user with this email already exists'] + const signUpSchema = passwordSchema.shape({ email: yup.string().email().required().label('Email'), }) @@ -40,7 +42,10 @@ const SignUpForm = () => { setCaptchaToken(null) captchaRef.current?.resetCaptcha() toast.error(`Failed to sign up: ${error.message}`) - Sentry.captureMessage('[CRITICAL] Failed to sign up: ' + error.message) + + if (!WHITELIST_ERRORS.includes(error.message)) { + Sentry.captureMessage('[CRITICAL] Failed to sign up: ' + error.message) + } }, }) diff --git a/apps/studio/pages/sign-in.tsx b/apps/studio/pages/sign-in.tsx index 46a3e85a26f..0a916583964 100644 --- a/apps/studio/pages/sign-in.tsx +++ b/apps/studio/pages/sign-in.tsx @@ -1,13 +1,14 @@ +import { Lock } from 'lucide-react' import Link from 'next/link' import { useRouter } from 'next/router' import { useEffect } from 'react' import SignInForm from 'components/interfaces/SignIn/SignInForm' import SignInWithGitHub from 'components/interfaces/SignIn/SignInWithGitHub' -import SignInWithSSO from 'components/interfaces/SignIn/SignInWithSSO' import { SignInLayout } from 'components/layouts' import { IS_PLATFORM } from 'lib/constants' import type { NextPageWithLayout } from 'types' +import { Button } from 'ui' const SignInPage: NextPageWithLayout = () => { const router = useRouter() @@ -24,7 +25,16 @@ const SignInPage: NextPageWithLayout = () => { <>
- +