The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
add password conditions helper
Alaister Young3a8fa4acdd42
diff --git a/studio/components/interfaces/SignIn/PasswordConditionsHelper.tsx b/studio/components/interfaces/SignIn/PasswordConditionsHelper.tsxnew file mode 100644index 00000000000..7f26e49039a--- /dev/null+++ b/studio/components/interfaces/SignIn/PasswordConditionsHelper.tsx@@ -0,0 +1,74 @@+export type PasswordConditionsHelperProps = {+ password: string+}++const PasswordConditionsHelper = ({ password }: PasswordConditionsHelperProps) => {+ const isEightCharactersLong = password.length >= 8+ const hasUppercase = /[A-Z]/.test(password)+ const hasLowercase = /[a-z]/.test(password)+ const hasNumber = /[0-9]/.test(password)+ const hasSpecialCharacter = /[!@#$%^&*()_+\-=\[\]{};`':"\\|,.<>\/?]/.test(password)++ return (+ <div className="text-sm">+ <PasswordCondition title="Must contain at least one uppercase letter" isMet={hasUppercase} />+ <PasswordCondition title="Must contain at least one lowercase letter" isMet={hasLowercase} />+ <PasswordCondition title="Must contain at least one number" isMet={hasNumber} />+ <PasswordCondition+ title="Must contain at least one special character"+ isMet={hasSpecialCharacter}+ />+ <PasswordCondition title="Must be at least 8 characters long" isMet={isEightCharactersLong} />+ </div>+ )+}++export default PasswordConditionsHelper++type PasswordConditionProps = {+ title: string+ isMet: boolean+}++const PasswordCondition = ({ title, isMet }: PasswordConditionProps) => {+ return (+ <div+ className={+ 'flex items-center gap-1 transition duration-200 ' ++ (isMet ? 'text-scale-1100' : 'text-scale-900')+ }+ >+ {isMet ? (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24"+ fill="currentColor"+ className="w-4 h-4"+ >+ <path+ fillRule="evenodd"+ d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z"+ clipRule="evenodd"+ />+ </svg>+ ) : (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ fill="none"+ stroke="currentColor"+ stroke-width={1.5}+ viewBox="0 0 24 24"+ className="w-4 h-4"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"+ />+ </svg>+ )}++ <p className="text-sm">{title}</p>+ </div>+ )+}diff --git a/studio/components/interfaces/SignIn/SignUpForm.tsx b/studio/components/interfaces/SignIn/SignUpForm.tsxindex 8cfdf8889a0..d57c950f059 100644--- a/studio/components/interfaces/SignIn/SignUpForm.tsx+++ b/studio/components/interfaces/SignIn/SignUpForm.tsx@@ -7,6 +7,7 @@ import { useRouter } from 'next/router'import { useRef, useState } from 'react'import { Button, Form, Input } from 'ui'import * as yup from 'yup'+import PasswordConditionsHelper from './PasswordConditionsHelper'const signUpSchema = passwordSchema.shape({email: yup.string().email().required().label('Email'),@@ -66,7 +67,7 @@ const SignUpForm = () => {validationSchema={signUpSchema}onSubmit={onSignUp}>- {({ isSubmitting }: { isSubmitting: boolean }) => {+ {({ isSubmitting, values }: { isSubmitting: boolean; values: any }) => {return (<div className="flex flex-col gap-4"><Input@@ -87,6 +88,8 @@ const SignUpForm = () => {disabled={isSubmitting}/>+ <PasswordConditionsHelper password={values.password} />+<div className="self-center"><HCaptcharef={captchaRef}diff --git a/studio/pages/sign-up.tsx b/studio/pages/sign-up.tsxindex 35e5c1eb5dc..5770049599e 100644--- a/studio/pages/sign-up.tsx+++ b/studio/pages/sign-up.tsx@@ -33,7 +33,7 @@ const SignUpPage: NextPageWithLayout = () => {}SignUpPage.getLayout = (page) => (- <SignInLayout heading="Get Started" subheading="Create a New Account">+ <SignInLayout heading="Get started" subheading="Create a new account">{page}</SignInLayout>)