Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion server/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ export async function validateResetPasswordToken(req, res) {
const user = await User.findOne({
resetPasswordToken: req.params.token,
resetPasswordExpires: { $gt: Date.now() }
}).exec();
})
.lean()
.exec();
if (!user) {
res.status(401).json({
success: false,
Expand Down
2 changes: 2 additions & 0 deletions server/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ projectSchema.methods.isSlugUnique = async function isSlugUnique() {
};
};

projectSchema.index({ user: 1 }, { collation: { locale: 'en', strength: 2 } });

export default mongoose.models.Project ||
mongoose.model('Project', projectSchema);
2 changes: 2 additions & 0 deletions server/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ userSchema.statics.findByEmailOrUsername = async function findByEmailOrUsername(
const foundUser = await user
.findOne(query)
.collation({ locale: 'en', strength: 2 })
.lean()
.exec();

return foundUser;
Expand Down Expand Up @@ -343,6 +344,7 @@ userSchema.statics.findByEmailAndUsername = async function findByEmailAndUsernam
const foundUser = await user
.findOne(query)
.collation({ locale: 'en', strength: 2 })
.lean()
.exec();

return foundUser;
Expand Down
4 changes: 2 additions & 2 deletions server/views/404Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ export const get404Sketch = async () => {
</html>`);

try {
const p5User = await User.findOne({ username: 'p5' }).exec();
const p5User = await User.findOne({ username: 'p5' }).lean().exec();

if (!p5User) {
return errorMessage;
}

const projects = await Project.find({ user: p5User._id }).exec();
const projects = await Project.find({ user: p5User._id }).lean().exec();

if (!projects.length) {
return errorMessage;
Expand Down