Refactor the authentication system to separate login and registration forms, implement password hashing, manage JWT tokens, and enable user data persistence in `backend/data/users.json`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 375ec6d3-d5af-4f82-ab81-5c60fd4a86a3 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 8d427c3d-aa60-488b-82c4-6cef148ba5d7 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/147e665c-8c0d-48ec-b0ad-fdc89cd4460f/375ec6d3-d5af-4f82-ab81-5c60fd4a86a3/e238nM8 Replit-Helium-Checkpoint-Created: true
22 lines
411 B
JavaScript
22 lines
411 B
JavaScript
// Input validation middleware
|
|
|
|
const validator = require('validator');
|
|
|
|
const validateEmail = (email) => {
|
|
return validator.isEmail(email);
|
|
};
|
|
|
|
const validatePassword = (password) => {
|
|
return typeof password === 'string' && password.length >= 6;
|
|
};
|
|
|
|
const validatePhone = (phone) => {
|
|
return validator.isMobilePhone(phone);
|
|
};
|
|
|
|
module.exports = {
|
|
validateEmail,
|
|
validatePassword,
|
|
validatePhone,
|
|
};
|