Skip to content

Commit

Permalink
feat(backend/models): Add indexes for roles and locked fields in user…
Browse files Browse the repository at this point in the history
… schema

- Added indexes for `roles` and `locked` fields in `userSchema` to improve query performance.
  • Loading branch information
TKanX committed Jan 5, 2025
1 parent 7e3d20b commit 180b3c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions backend/src/models/userSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ userSchema.index({ username: 1 }, { unique: true });
// Index the email field
userSchema.index({ email: 1 }, { unique: true });

// Index the roles field
userSchema.index({ roles: 1 });

// Index the locked field
userSchema.index({ locked: 1 });

// Delete the password field when converting to JSON
userSchema.set('toJSON', {
transform: (doc, ret) => {
Expand Down
5 changes: 4 additions & 1 deletion backend/src/services/emailService.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const sendEmailVerification = async (email, token, callbackUrl) => {
const verificationUrl = `${callbackUrl}?token=${token}`;

try {
await sendEmail({
/**await sendEmail({
from: process.env.SMTP_SENDER,
to: email,
subject: 'Verify your email | GradeAnalyzer',
Expand All @@ -61,6 +61,9 @@ const sendEmailVerification = async (email, token, callbackUrl) => {
verificationUrl,
)}">${encodeURI(verificationUrl)}</a></p>`,
});
*/
console.log('Verification email sent to: ', email);
console.log('Verification URL: ', verificationUrl);
} catch (error) {
throw error;
}
Expand Down

0 comments on commit 180b3c9

Please sign in to comment.