Skip to content

Commit

Permalink
feat : allow specific character and accept alphanumeric on pinInput
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanneGrenet committed Aug 9, 2024
1 parent 322208b commit 27f8a70
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/Form/FieldOtp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const FieldOtp = <
isInvalid={fieldState.invalid}
isDisabled={props.isDisabled}
otp
type="alphanumeric"
id={id}
onComplete={(v) => {
props.onComplete?.(v);
Expand Down
1 change: 1 addition & 0 deletions src/features/auth/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const VALIDATION_CODE_MOCKED = '000000';
export const ALLOWED_CHARACTERS = 'abcdefghjkmnpqrstuvwxyz23456789';
export const VALIDATION_RETRY_DELAY_IN_SECONDS = 2;
export const VALIDATION_RETRY_ALLOWED_BEFORE_DELAY = 3;
export const VALIDATION_TOKEN_EXPIRATION_IN_MINUTES = 5;
Expand Down
5 changes: 3 additions & 2 deletions src/server/config/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { TRPCError } from '@trpc/server';
import bcrypt from 'bcrypt';
import dayjs from 'dayjs';
import { cookies, headers } from 'next/headers';
import { alphabet, generateRandomString } from 'oslo/crypto';
import { generateRandomString } from 'oslo/crypto';

import { env } from '@/env.mjs';
import {
ALLOWED_CHARACTERS,
VALIDATION_CODE_MOCKED,
getValidationRetryDelayInSeconds,
} from '@/features/auth/utils';
Expand Down Expand Up @@ -65,7 +66,7 @@ export async function generateCode() {
const code =
env.NODE_ENV === 'development' || env.NEXT_PUBLIC_IS_DEMO
? VALIDATION_CODE_MOCKED
: generateRandomString(6, alphabet('a-z', '0-9'));
: generateRandomString(6, ALLOWED_CHARACTERS);
return {
hashed: await bcrypt.hash(code, 12),
readable: code,
Expand Down

0 comments on commit 27f8a70

Please sign in to comment.