Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add CTA for support form

Joshen Lim30412056f123
diff --git a/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx b/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx
index db9b8106400..0e35c801c7b 100644
--- a/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx
+++ b/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx
@@ -1,5 +1,5 @@
import Image from 'next/image'
-import { Dispatch, SetStateAction, useEffect, useState } from 'react'
+import { Dispatch, SetStateAction, useState } from 'react'
import { Input, Modal } from 'ui'
import ConfirmationModal from 'components/ui/ConfirmationModal'
@@ -15,33 +15,9 @@ interface AddNewFactorModalProps {
}
const AddNewFactorModal = ({ onClose }: AddNewFactorModalProps) => {
- const [verificationComplete, setVerificationComplete] = useState(false)
// Generate a name with a number between 0 and 1000
const [name, setName] = useState(`App ${Math.floor(Math.random() * 1000)}`)
-
- const {
- data,
- mutate: enroll,
- reset: resetEnrollment,
- isLoading: isEnrolling,
- } = useMfaEnrollMutation()
- const { mutate: unenroll } = useMfaUnenrollMutation()
-
- useEffect(() => {
- return () => {
- // when the modal is closed, if there's a factor id which hasn't been verified, unenroll it
- if (data?.id && !verificationComplete) {
- // delete the internal state of enroll mutation so that the next time enroll is called,
- // it makes an API call
- resetEnrollment()
- unenroll({ factorId: data.id })
- }
- }
- }, [data])
-
- useEffect(() => {
- // unenroll({ factorId: '599d65b7-8efe-4295-9baf-6e1bf5360c20' })
- }, [])
+ const { data, mutate: enroll, isLoading: isEnrolling } = useMfaEnrollMutation()
return !data ? (
<FirstStep
@@ -56,10 +32,7 @@ const AddNewFactorModal = ({ onClose }: AddNewFactorModalProps) => {
factorName={name}
factor={data}
isLoading={isEnrolling}
- onSuccess={() => {
- setVerificationComplete(true)
- onClose()
- }}
+ onSuccess={() => onClose()}
onClose={onClose}
/>
)
@@ -92,16 +65,14 @@ const FirstStep = ({ name, enroll, setName, isEnrolling, onClose }: FirstStepPro
}}
>
<Modal.Content>
- <>
- <div className="pt-6 pb-5">
- <Input
- label="Provide a name to identify this app"
- descriptionText="A string will be randomly generated if a name is not provided"
- value={name}
- onChange={(e) => setName(e.target.value)}
- />
- </div>
- </>
+ <div className="pt-6 pb-5">
+ <Input
+ label="Provide a name to identify this app"
+ descriptionText="A string will be randomly generated if a name is not provided"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ />
+ </div>
</Modal.Content>
</ConfirmationModal>
)
@@ -127,9 +98,7 @@ const SecondStep = ({ factorName, factor, isLoading, onSuccess, onClose }: Secon
const { ui } = useStore()
const [code, setCode] = useState('')
- const { mutate: unenroll, isLoading: isDeleting } = useMfaUnenrollMutation({
- onSuccess: () => onClose(),
- })
+ const { mutate: unenroll } = useMfaUnenrollMutation({ onSuccess: () => onClose() })
const { mutate: challengeAndVerify, isLoading: isVerifying } = useMfaChallengeAndVerifyMutation({
onError: (error) => {
@@ -155,10 +124,7 @@ const SecondStep = ({ factorName, factor, isLoading, onSuccess, onClose }: Secon
buttonLabel="Confirm"
buttonLoadingLabel="Confirming"
loading={isVerifying}
- onSelectCancel={() => {
- // unenroll({ factorId: factor.id })
- onClose()
- }}
+ onSelectCancel={() => unenroll({ factorId: factor.id })}
onSelectConfirm={() => challengeAndVerify({ factorId: factor.id, code })}
>
<Modal.Content>
diff --git a/studio/components/interfaces/SignIn/SignInMfaForm.tsx b/studio/components/interfaces/SignIn/SignInMfaForm.tsx
index 08bcdbd4b80..72b7da3a9f9 100644
--- a/studio/components/interfaces/SignIn/SignInMfaForm.tsx
+++ b/studio/components/interfaces/SignIn/SignInMfaForm.tsx
@@ -6,6 +6,7 @@ import { useMfaChallengeAndVerifyMutation } from 'data/profile/mfa-challenge-and
import { useMfaListFactorsQuery } from 'data/profile/mfa-list-factors-query'
import { useStore } from 'hooks'
import { usePushNext } from 'hooks/misc/useAutoAuthRedirect'
+import Link from 'next/link'
import { useEffect, useState } from 'react'
import { Button, Form, IconLock, Input } from 'ui'
import { object, string } from 'yup'
@@ -71,63 +72,75 @@ const SignInMfaForm = () => {
}
return (
- <Form
- validateOnBlur
- id="sign-in-mfa-form"
- initialValues={{ code: '' }}
- validationSchema={signInSchema}
- onSubmit={onSignIn}
- >
- {() => (
- <div className="flex flex-col gap-4">
- <Input
- id="code"
- name="code"
- type="text"
- autoFocus
- icon={<IconLock />}
- placeholder="XXXXXX"
- disabled={isLoading}
- autoComplete="off"
- spellCheck="false"
- autoCapitalize="none"
- autoCorrect="off"
- label={
- selectedFactor && factors?.totp.length === 2
- ? `Code generated by ${selectedFactor.friendly_name}`
- : null
- }
- />
+ <>
+ <Form
+ validateOnBlur
+ id="sign-in-mfa-form"
+ initialValues={{ code: '' }}
+ validationSchema={signInSchema}
+ onSubmit={onSignIn}
+ >
+ {() => (
+ <div className="flex flex-col gap-4">
+ <Input
+ id="code"
+ name="code"
+ type="text"
+ autoFocus
+ icon={<IconLock />}
+ placeholder="XXXXXX"
+ disabled={isLoading}
+ autoComplete="off"
+ spellCheck="false"
+ autoCapitalize="none"
+ autoCorrect="off"
+ label={
+ selectedFactor && factors?.totp.length === 2
+ ? `Code generated by ${selectedFactor.friendly_name}`
+ : null
+ }
+ />
- <Button
- block
- form="sign-in-mfa-form"
- htmlType="submit"
- size="large"
- disabled={isLoading}
- loading={isLoading}
- >
- {isLoading ? 'Verifying' : 'Verify'}
- </Button>
- {factors?.totp.length === 2 && (
- <div className="text-sm flex flex-col items-center w-full gap-1">
- <div>
- <span className="text-scale-900">Having problems?</span>{' '}
- <a
- className="text-white hover:border-b border-white"
- href="#"
- onClick={() =>
- setSelectedFactor(factors.totp.find((f) => f.id !== selectedFactor?.id)!)
- }
- >{`Authenticate using ${
- factors.totp.find((f) => f.id !== selectedFactor?.id)?.friendly_name
- }?`}</a>
+ <Button
+ block
+ form="sign-in-mfa-form"
+ htmlType="submit"
+ size="large"
+ disabled={isLoading}
+ loading={isLoading}
+ >
+ {isLoading ? 'Verifying' : 'Verify'}
+ </Button>
+ {factors?.totp.length === 2 && (
+ <div className="text-sm flex flex-col items-center w-full gap-1">
+ <div>
+ <span className="text-scale-900">Having problems?</span>{' '}
+ <a
+ className="text-white hover:border-b border-white"
+ href="#"
+ onClick={() =>
+ setSelectedFactor(factors.totp.find((f) => f.id !== selectedFactor?.id)!)
+ }
+ >{`Authenticate using ${
+ factors.totp.find((f) => f.id !== selectedFactor?.id)?.friendly_name
+ }?`}</a>
+ </div>
</div>
- </div>
- )}
+ )}
+ </div>
+ )}
+ </Form>
+ <div className="self-center my-8 text-sm">
+ <div>
+ <span className="text-scale-1000">Unable to log in?</span>{' '}
+ <Link href="/support/new?subject=Unable%20to%20log%20in%20via%20MFA">
+ <a className="underline transition text-scale-1100 hover:text-scale-1200">
+ Reach out via support
+ </a>
+ </Link>
</div>
- )}
- </Form>
+ </div>
+ </>
)
}