feat: additional valid password (#1456)

This commit is contained in:
Dunsin
2024-12-27 06:02:45 +01:00
committed by GitHub
parent 32857bbfeb
commit 39b1c5bbec
10 changed files with 30 additions and 26 deletions

View File

@@ -2,7 +2,7 @@ import cors from '@/lib/cors';
import { getUserMonthlyGrowth } from '@/lib/growth/get-user-monthly-growth'; import { getUserMonthlyGrowth } from '@/lib/growth/get-user-monthly-growth';
export async function GET(request: Request) { export async function GET(request: Request) {
const totalUsers = await getUserMonthlyGrowth("cumulative"); const totalUsers = await getUserMonthlyGrowth('cumulative');
return cors( return cors(
request, request,

View File

@@ -30,10 +30,10 @@ function isOriginAllowed(origin: string, allowed: StaticOrigin): boolean {
return Array.isArray(allowed) return Array.isArray(allowed)
? allowed.some((o) => isOriginAllowed(origin, o)) ? allowed.some((o) => isOriginAllowed(origin, o))
: typeof allowed === 'string' : typeof allowed === 'string'
? origin === allowed ? origin === allowed
: allowed instanceof RegExp : allowed instanceof RegExp
? allowed.test(origin) ? allowed.test(origin)
: !!allowed; : !!allowed;
} }
function getOriginHeaders(reqOrigin: string | undefined, origin: StaticOrigin) { function getOriginHeaders(reqOrigin: string | undefined, origin: StaticOrigin) {

View File

@@ -178,7 +178,7 @@ export const DropdownField = ({
)} )}
{!field.inserted && ( {!field.inserted && (
<p className="group-hover:text-primary text-muted-foreground flex flex-col items-center justify-center duration-200 "> <p className="group-hover:text-primary text-muted-foreground flex flex-col items-center justify-center duration-200">
<Select value={localChoice} onValueChange={handleSelectItem}> <Select value={localChoice} onValueChange={handleSelectItem}>
<SelectTrigger <SelectTrigger
className={cn( className={cn(

View File

@@ -205,7 +205,7 @@ export const NameField = ({ field, recipient, onSignField, onUnsignField }: Name
<div className="flex w-full flex-1 flex-nowrap gap-4"> <div className="flex w-full flex-1 flex-nowrap gap-4">
<Button <Button
type="button" type="button"
className="dark:bg-muted dark:hover:bg-muted/80 flex-1 bg-black/5 hover:bg-black/10" className="dark:bg-muted dark:hover:bg-muted/80 flex-1 bg-black/5 hover:bg-black/10"
variant="secondary" variant="secondary"
onClick={() => { onClick={() => {
setShowFullNameModal(false); setShowFullNameModal(false);

View File

@@ -318,7 +318,7 @@ export const NumberField = ({ field, recipient, onSignField, onUnsignField }: Nu
<div className="flex w-full flex-1 flex-nowrap gap-4"> <div className="flex w-full flex-1 flex-nowrap gap-4">
<Button <Button
type="button" type="button"
className="dark:bg-muted dark:hover:bg-muted/80 flex-1 bg-black/5 hover:bg-black/10" className="dark:bg-muted dark:hover:bg-muted/80 flex-1 bg-black/5 hover:bg-black/10"
variant="secondary" variant="secondary"
onClick={() => { onClick={() => {
setShowRadioModal(false); setShowRadioModal(false);

View File

@@ -214,15 +214,15 @@ export const TextField = ({ field, recipient, onSignField, onUnsignField }: Text
parsedField?.label && parsedField.label.length < 20 parsedField?.label && parsedField.label.length < 20
? parsedField.label ? parsedField.label
: parsedField?.label : parsedField?.label
? parsedField?.label.substring(0, 20) + '...' ? parsedField?.label.substring(0, 20) + '...'
: undefined; : undefined;
const textDisplay = const textDisplay =
parsedField?.text && parsedField.text.length < 20 parsedField?.text && parsedField.text.length < 20
? parsedField.text ? parsedField.text
: parsedField?.text : parsedField?.text
? parsedField?.text.substring(0, 20) + '...' ? parsedField?.text.substring(0, 20) + '...'
: undefined; : undefined;
const fieldDisplayName = labelDisplay ? labelDisplay : textDisplay; const fieldDisplayName = labelDisplay ? labelDisplay : textDisplay;
const charactersRemaining = (parsedFieldMeta?.characterLimit ?? 0) - (localText.length ?? 0); const charactersRemaining = (parsedFieldMeta?.characterLimit ?? 0) - (localText.length ?? 0);
@@ -325,7 +325,7 @@ export const TextField = ({ field, recipient, onSignField, onUnsignField }: Text
<div className="mt-4 flex w-full flex-1 flex-nowrap gap-4"> <div className="mt-4 flex w-full flex-1 flex-nowrap gap-4">
<Button <Button
type="button" type="button"
className="dark:bg-muted dark:hover:bg-muted/80 flex-1 bg-black/5 hover:bg-black/10" className="dark:bg-muted dark:hover:bg-muted/80 flex-1 bg-black/5 hover:bg-black/10"
variant="secondary" variant="secondary"
onClick={() => { onClick={() => {
setShowCustomTextModal(false); setShowCustomTextModal(false);

View File

@@ -47,10 +47,7 @@ export const StackAvatar = ({ first, zIndex, fallbackText = '', type }: StackAva
return ( return (
<Avatar <Avatar
className={` className={` ${zIndexClass} ${firstClass} dark:border-border h-10 w-10 border-2 border-solid border-white`}
${zIndexClass}
${firstClass}
dark:border-border h-10 w-10 border-2 border-solid border-white`}
> >
<AvatarFallback className={classes}>{fallbackText}</AvatarFallback> <AvatarFallback className={classes}>{fallbackText}</AvatarFallback>
</Avatar> </Avatar>

View File

@@ -70,6 +70,7 @@ export const ZSignUpFormV2Schema = z
}, },
{ {
message: msg`Password should not be common or based on personal information`.id, message: msg`Password should not be common or based on personal information`.id,
path: ['password'],
}, },
); );

View File

@@ -10,14 +10,20 @@ export const ZCurrentPasswordSchema = z
export const ZPasswordSchema = z export const ZPasswordSchema = z
.string() .string()
.regex(new RegExp('.*[A-Z].*'), { message: 'One uppercase character' })
.regex(new RegExp('.*[a-z].*'), { message: 'One lowercase character' })
.regex(new RegExp('.*\\d.*'), { message: 'One number' })
.regex(new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), {
message: 'One special character is required',
})
.min(8, { message: 'Must be at least 8 characters in length' }) .min(8, { message: 'Must be at least 8 characters in length' })
.max(72, { message: 'Cannot be more than 72 characters in length' }); .max(72, { message: 'Cannot be more than 72 characters in length' })
.refine((value) => value.length > 25 || /[A-Z]/.test(value), {
message: 'One uppercase character',
})
.refine((value) => value.length > 25 || /[a-z]/.test(value), {
message: 'One lowercase character',
})
.refine((value) => value.length > 25 || /\d/.test(value), {
message: 'One number',
})
.refine((value) => value.length > 25 || /[`~<>?,./!@#$%^&*()\-_"'+=|{}[\];:\\]/.test(value), {
message: 'One special character is required',
});
export const ZSignUpMutationSchema = z.object({ export const ZSignUpMutationSchema = z.object({
name: z.string().min(1), name: z.string().min(1),

View File

@@ -1086,8 +1086,8 @@ export const AddFieldsFormPartial = ({
{emptyCheckboxFields.length > 0 {emptyCheckboxFields.length > 0
? 'Checkbox' ? 'Checkbox'
: emptyRadioFields.length > 0 : emptyRadioFields.length > 0
? 'Radio' ? 'Radio'
: 'Select'}{' '} : 'Select'}{' '}
field. field.
</Trans> </Trans>
</li> </li>