Skip to content

Commit 203c637

Browse files
committed
Add SignupDataSchema validation to signup function
1 parent c25ec32 commit 203c637

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

frontend/src/services/authService.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
RefreshTokenSchema,
99
TokenPairResponseSchema,
1010
} from "@/types/Token";
11-
import { LoginCredentials, SignupData } from "@/types/AuthCredentials";
11+
import {
12+
LoginCredentials,
13+
SignupData,
14+
SignupDataSchema,
15+
} from "@/types/AuthCredentials";
1216
import { LogoutResponse, LogoutResposeSchema } from "@/types/AuthResponses";
1317
import { getAccessToken } from "@/lib/auth";
1418

@@ -61,6 +65,7 @@ export async function signup(
6165
signupData: SignupData
6266
): Promise<AccessTokenResponse> {
6367
try {
68+
const parsedSignupData = SignupDataSchema.parse(signupData);
6469
const res: Response = await fetch(
6570
process.env.PUBLIC_API_URL + `/api/auth/local/signup`,
6671
{
@@ -69,7 +74,7 @@ export async function signup(
6974
headers: {
7075
"Content-Type": "application/json",
7176
},
72-
body: JSON.stringify(signupData),
77+
body: JSON.stringify(parsedSignupData),
7378
}
7479
);
7580

0 commit comments

Comments
 (0)