Mobcash Password Change -
if (newPassword.length < 6) return res.status(400).json( msg: 'Password must be at least 6 characters' );
.message-box.error display: block; background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb;
#strengthText display: block; font-size: 0.7rem; margin-top: 4px;
if (newPassword !== confirmNewPassword) return res.status(400).json( msg: 'New passwords do not match' ); Mobcash Password Change
const PORT = process.env.PORT || 5000; app.listen(PORT, () => console.log( Server running on port $PORT )); 1. HTML ( frontend/change-password.html ) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <title>Mobcash - Change Password</title> <link rel="stylesheet" href="change-password.css"> </head> <body> <div class="container"> <div class="card"> <div class="header"> <img src="https://via.placeholder.com/50?text=M" alt="Mobcash Logo" class="logo"> <h1>Change Password</h1> <p>Secure your Mobcash account</p> </div> <form id="passwordChangeForm"> <div class="input-group"> <label>Current Password</label> <div class="password-wrapper"> <input type="password" id="currentPassword" placeholder="Enter current password" required> <span class="toggle-pw" data-target="currentPassword">👁️</span> </div> </div>
.input-group label display: block; margin-bottom: 8px; font-weight: 600; color: #444; font-size: 0.9rem;
.error-msg color: #e74c3c; font-size: 0.7rem; display: block; margin-top: 4px; if (newPassword
);
if (confirmPw.value) validateMatch(); );
// 5. Optional: Invalidate all existing sessions (if using JWT, you'd rotate token) // Here we just return success Verify current password const isMatch = await user
body background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
// 3. Verify current password const isMatch = await user.comparePassword(currentPassword); if (!isMatch) return res.status(401).json( msg: 'Current password is incorrect' );
// Toggle password visibility document.querySelectorAll('.toggle-pw').forEach(icon => icon.addEventListener('click', (e) => const targetId = icon.getAttribute('data-target'); const input = document.getElementById(targetId); if (input.type === 'password') input.type = 'text'; icon.textContent = '🙈'; else input.type = 'password'; icon.textContent = '👁️';