Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix: unify password validation error to show all requirements at once

jubnlb88a8fcbb55c
diff --git a/server/src/services/passwordPolicy.ts b/server/src/services/passwordPolicy.ts
index ad817d108..9b20143e3 100644
--- a/server/src/services/passwordPolicy.ts
+++ b/server/src/services/passwordPolicy.ts
@@ -18,10 +18,11 @@ export function validatePassword(password: string): { ok: boolean; reason?: stri
return { ok: false, reason: 'Password is too common. Please choose a unique password.' };
}
- if (!/[A-Z]/.test(password)) return { ok: false, reason: 'Password must contain at least one uppercase letter' };
- if (!/[a-z]/.test(password)) return { ok: false, reason: 'Password must contain at least one lowercase letter' };
- if (!/[0-9]/.test(password)) return { ok: false, reason: 'Password must contain at least one number' };
- if (!/[^A-Za-z0-9]/.test(password)) return { ok: false, reason: 'Password must contain at least one special character' };
+ const requirementsMessage = 'Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character';
+ if (!/[A-Z]/.test(password)) return { ok: false, reason: requirementsMessage };
+ if (!/[a-z]/.test(password)) return { ok: false, reason: requirementsMessage };
+ if (!/[0-9]/.test(password)) return { ok: false, reason: requirementsMessage };
+ if (!/[^A-Za-z0-9]/.test(password)) return { ok: false, reason: requirementsMessage };
return { ok: true };
}