Skip to content

Commit ac92a8a

Browse files
committed
refactor: simplify token and session expiration configurations
1 parent 6088cc1 commit ac92a8a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

.env.development

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ CLIENT_SIDE_URL="http://localhost:3001"
66

77
# JWT
88
JWT_SECRET="some-secret"
9-
JWT_EXPIRES_IN="1h"
9+
JWT_EXPIRES_IN=3600
1010

1111
# NODE_ENV
1212
NODE_ENV="development"
1313

1414
# SESSION
15-
SESSION_EXPIRES_IN="1d"
15+
SESSION_EXPIRES_IN=86400
1616

1717
# AUTH
18-
PASSWORD_RESET_TOKEN_EXPIRES_IN="1d"
19-
SET_PASSWORD_TOKEN_EXPIRES_IN="1d"
18+
PASSWORD_RESET_TOKEN_EXPIRES_IN=86400
19+
SET_PASSWORD_TOKEN_EXPIRES_IN=86400
2020
SET_SESSION=0
2121

2222
# DATABSES

src/config/config.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ const configSchema = z.object({
1717
SMTP_PASSWORD: z.string().min(1).optional(),
1818
CLIENT_SIDE_URL: z.string().url(),
1919
JWT_SECRET: z.string().min(1),
20-
JWT_EXPIRES_IN: z.string().regex(/^(\d+d|\d+h|\d+m|\d+s)$/),
21-
SESSION_EXPIRES_IN: z.string().min(1).transform(Number),
22-
PASSWORD_RESET_TOKEN_EXPIRES_IN: z.string().min(1).transform(Number),
23-
SET_PASSWORD_TOKEN_EXPIRES_IN: z.string().min(1).transform(Number),
20+
JWT_EXPIRES_IN: z.string().default("86400").transform(Number),
21+
SESSION_EXPIRES_IN: z.string().default("86400").transform(Number),
22+
PASSWORD_RESET_TOKEN_EXPIRES_IN: z.string().default("86400").transform(Number),
23+
SET_PASSWORD_TOKEN_EXPIRES_IN: z.string().default("86400").transform(Number),
2424
STATIC_OTP: z.enum(["1", "0"]).transform(Number).optional(),
2525
NODE_ENV: z
2626
.union([z.literal("production"), z.literal("development")])

src/modules/auth/auth.schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const loginUserByEmailSchema = z.object({
4747
email: z
4848
.string({ required_error: "Email is required" })
4949
.email({ message: "Email is not valid" }),
50-
password: passwordValidationSchema("Password"),
50+
password: z.string().min(1, "Password is required"),
5151
});
5252

5353
export type RegisterUserByEmailSchemaType = z.infer<

0 commit comments

Comments
 (0)