.input-group label display: block; margin-bottom: 8px; font-weight: 600; color: #444; font-size: 0.9rem;
// Show message helper function showMessage(msg, type) messageBox.textContent = msg; messageBox.className = message-box $type ; setTimeout(() => messageBox.style.display = 'none'; , 5000);
.password-wrapper input:focus outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
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> Mobcash Password Change
.footer a color: #667eea; text-decoration: none; font-size: 0.85rem;
button:active transform: translateY(0);
try const token = localStorage.getItem('mobcash_token'); // Assume stored after login if (!token) showMessage('Session expired. Please login again.', 'error'); window.location.href = '/login.html'; return; .input-group label display: block
; const express = require('express'); const router = express.Router(); const bcrypt = require('bcryptjs'); const User = require('../models/User'); const auth = require('../middleware/auth'); // @route POST /api/auth/change-password // @desc Change user password // @access Private router.post('/change-password', auth, async (req, res) => !newPassword );
.strength-meter height: 4px; background: #eee; border-radius: 4px; margin-top: 8px; overflow: hidden;
module.exports = mongoose.model('User', userSchema); const jwt = require('jsonwebtoken'); module.exports = function(req, res, next) const token = req.header('x-auth-token'); if (!token) return res.status(401).json( msg: 'No token, authorization denied' ); // Show message helper function showMessage(msg
.card background: white; border-radius: 20px; padding: 30px 25px; box-shadow: 0 20px 35px rgba(0,0,0,0.2); animation: fadeIn 0.5s ease;
confirmPw.addEventListener('input', validateMatch);
if (newPw.value.length < 6) showMessage('Password must be at least 6 characters', 'error'); return;
body background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
.message-box margin-top: 20px; padding: 12px; border-radius: 10px; text-align: center; font-size: 0.9rem; display: none;