20260607 - login, add scene, add hotspot
This commit is contained in:
@@ -22,16 +22,15 @@ const userSchema = new mongoose.Schema({
|
||||
});
|
||||
|
||||
// Hash password before saving
|
||||
userSchema.pre('save', async function (next) {
|
||||
userSchema.pre('save', async function () {
|
||||
if (!this.isModified('password')) {
|
||||
return next();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const salt = await bcrypt.genSalt(10);
|
||||
this.password = await bcrypt.hash(this.password, salt);
|
||||
next();
|
||||
} catch (error) {
|
||||
next(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user