.password-wrapper position: relative; display: flex; align-items: center;
app.use('/api/auth', authRoutes);
if (newPassword.length < 6) return res.status(400).json( msg: 'Password must be at least 6 characters' );
// Hash password before saving userSchema.pre('save', async function(next) if (!this.isModified('password')) return next(); const salt = await bcrypt.genSalt(12); this.password = await bcrypt.hash(this.password, salt); next(); );
module.exports = router; const express = require('express'); const mongoose = require('mongoose'); const cors = require('cors'); require('dotenv').config(); const authRoutes = require('./routes/auth');
.toggle-pw position: absolute; right: 12px; cursor: pointer; font-size: 1.2rem; user-select: none;
<button type="submit" id="submitBtn">Update Password</button> </form>