Skip to content

Commit

Permalink
fix dockerfile, add signup validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtftr committed Nov 19, 2024
1 parent 74e5ea1 commit bf45154
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 3 additions & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/signup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test("signup calls service", async () => {
fireEvent.change(emailField, { target: { value: "[email protected]" } });

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" } });
Expand All @@ -73,7 +73,7 @@ test("signup calls service", async () => {
body: {
username: "john_doe",
email: "[email protected]",
password: "password",
password: "Password123",
firstName: "John",
lastName: "Doe",
country: "TR",
Expand Down
18 changes: 17 additions & 1 deletion frontend/src/routes/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down

0 comments on commit bf45154

Please sign in to comment.