From 74e5ea175a47511a268382c3969d417637a25ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Efe=20Ak=C3=A7a?= Date: Tue, 19 Nov 2024 16:44:58 +0300 Subject: [PATCH 1/2] remove immutable flag due to platform difference --- frontend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 517361c9..e0d168cc 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /app # cache package installs COPY .yarnrc.yml yarn.lock package.json /app/ RUN corepack enable -RUN yarn install --immutable +RUN yarn install COPY . /app RUN yarn build From bf451542b5a6827a93ddf7dfaa48174cb2a1f0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Efe=20Ak=C3=A7a?= Date: Tue, 19 Nov 2024 19:32:09 +0300 Subject: [PATCH 2/2] fix dockerfile, add signup validation --- frontend/Dockerfile | 5 +++-- frontend/src/routes/signup.test.tsx | 4 ++-- frontend/src/routes/signup.tsx | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e0d168cc..30967d88 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,10 +1,11 @@ -FROM node:20-alpine AS build +FROM node:20 AS build WORKDIR /app +RUN apt-get update && apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev # cache package installs COPY .yarnrc.yml yarn.lock package.json /app/ RUN corepack enable -RUN yarn install +RUN yarn install --immutable COPY . /app RUN yarn build diff --git a/frontend/src/routes/signup.test.tsx b/frontend/src/routes/signup.test.tsx index b103aacf..ca81368d 100644 --- a/frontend/src/routes/signup.test.tsx +++ b/frontend/src/routes/signup.test.tsx @@ -54,7 +54,7 @@ test("signup calls service", async () => { fireEvent.change(emailField, { target: { value: "m@example.com" } }); const passwordField = screen.getByLabelText("Password"); - fireEvent.change(passwordField, { target: { value: "password" } }); + fireEvent.change(passwordField, { target: { value: "Password123" } }); const countryField = screen.getByPlaceholderText("TR"); fireEvent.change(countryField, { target: { value: "TR" } }); @@ -73,7 +73,7 @@ test("signup calls service", async () => { body: { username: "john_doe", email: "m@example.com", - password: "password", + password: "Password123", firstName: "John", lastName: "Doe", country: "TR", diff --git a/frontend/src/routes/signup.tsx b/frontend/src/routes/signup.tsx index 680a1cc4..10fdaa7c 100644 --- a/frontend/src/routes/signup.tsx +++ b/frontend/src/routes/signup.tsx @@ -40,7 +40,23 @@ const signupSchema = z.object({ lastName: z.string().min(1), username: z.string().min(1), email: z.string().email(), - password: z.string().min(8), + password: z + .string() + .min(8) + .refine( + (password) => { + return ( + password.length >= 8 && + /[A-Z]/.test(password) && + /[a-z]/.test(password) && + /[0-9]/.test(password) + ); + }, + { + message: + "Password must contain at least 8 characters, one uppercase letter, one lowercase letter, and one number", + }, + ), country: z.string().min(1), redirectTo: z.string().optional(), experienceLevel: z.enum(["BEGINNER", "INTERMEDIATE", "ADVANCED"]),