20260607 - login, add scene, add hotspot

This commit is contained in:
2026-06-07 21:31:31 +07:00
parent 10d2e07297
commit 5ba6e37039
29 changed files with 1064 additions and 73 deletions
+22
View File
@@ -37,6 +37,28 @@ const sceneSchema = new mongoose.Schema({
sharedWith: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
}],
hotspots: [{
pitch: {
type: Number,
required: true
},
yaw: {
type: Number,
required: true
},
text: {
type: String,
trim: true
},
description: {
type: String,
trim: true
},
targetSceneId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Scene'
}
}]
}, {
timestamps: true
+3 -4
View File
@@ -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;
}
});