Skip to content

Commit

Permalink
Fixed bug adding zod validation of password before sending OTP
Browse files Browse the repository at this point in the history
  • Loading branch information
Dyuti01 committed Jan 15, 2025
1 parent 7b69bc9 commit 0d1bc76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions apps/web/lib/actions/send-otp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { getIP } from "../api/utils";
import { generateOTP } from "../auth";
import { EMAIL_OTP_EXPIRY_IN } from "../auth/constants";
import z from "../zod";
import { emailSchema } from "../zod/schemas/auth";
import { emailSchema, passwordSchema } from "../zod/schemas/auth";
import { throwIfAuthenticated } from "./auth/throw-if-authenticated";
import { actionClient } from "./safe-action";

const schema = z.object({
email: emailSchema,
password: passwordSchema
});

// Send OTP to email to verify account
Expand All @@ -26,7 +27,7 @@ export const sendOtpAction = actionClient
})
.use(throwIfAuthenticated)
.action(async ({ parsedInput }) => {
const { email } = parsedInput;
const { email, password } = parsedInput;

const { success } = await ratelimit(2, "1 m").limit(`send-otp:${getIP()}`);

Expand Down
4 changes: 2 additions & 2 deletions apps/web/ui/auth/register/signup-email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export const SignUpEmail = () => {
setStep("verify");
},
onError: ({ error }) => {
toast.error(error.serverError);
toast.error(error.serverError||error.validationErrors?.email||error.validationErrors?.password||error.bindArgsValidationErrors);
},
});

return (
<>
<form
onSubmit={handleSubmit((data) => executeAsync({ email: data.email }))}
onSubmit={handleSubmit((data) => executeAsync({ email: data.email, password:data.password }))}
>
<div className="flex flex-col space-y-4">
<Input
Expand Down

0 comments on commit 0d1bc76

Please sign in to comment.