Mobcash Password Change Apr 2026
// 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(); );
#strengthText display: block; font-size: 0.7rem; margin-top: 4px;
mongoose.connect(process.env.MONGO_URI, useNewUrlParser: true, useUnifiedTopology: true ).then(() => console.log('MongoDB connected')); Mobcash Password Change
// Compare password method userSchema.methods.comparePassword = async function(candidatePassword) return await bcrypt.compare(candidatePassword, this.password); ;
.header h1 font-size: 1.8rem; color: #333; margin-bottom: 5px; // Hash password before saving userSchema
button width: 100%; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; padding: 14px; border-radius: 12px; font-size: 1rem; font-weight: bold; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; margin-top: 10px;
body background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; // Hash password before saving userSchema.pre('save'
<button type="submit" id="submitBtn">Update Password</button> </form>
<div id="messageBox" class="message-box"></div> <div class="footer"> <a href="#">Back to Dashboard</a> </div> </div> </div> <script src="change-password.js"></script> </body> </html> * margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
.strength-meter height: 4px; background: #eee; border-radius: 4px; margin-top: 8px; overflow: hidden;
.header text-align: center; margin-bottom: 30px;