diff --git a/backend/config/passportConfig.js b/backend/config/passportConfig.js index 842f50ca..173ff8a9 100644 --- a/backend/config/passportConfig.js +++ b/backend/config/passportConfig.js @@ -7,7 +7,7 @@ passport.use( { usernameField: "email" }, async (email, password, done) => { try { - const user = await User.findOne( {email} ); + const user = await User.findOne( {email} ).select("+password");; if (!user) { return done(null, false, { message: 'Email is invalid '}); } @@ -38,7 +38,10 @@ passport.serializeUser((user, done) => { passport.deserializeUser(async (id, done) => { try { const user = await User.findById(id); - done(null, user); + if (!user) { + return done(null, false); + } + done(null,user); } catch (err) { done(err, null); } diff --git a/backend/models/User.js b/backend/models/User.js index eb506ed5..fed589a9 100644 --- a/backend/models/User.js +++ b/backend/models/User.js @@ -19,11 +19,15 @@ const UserSchema = new mongoose.Schema({ }); // ✅ FIXED: no next() -UserSchema.pre('save', async function () { - if (!this.isModified('password')) return; - - const salt = await bcrypt.genSalt(10); - this.password = await bcrypt.hash(this.password, salt); +UserSchema.pre('save', async function (next) { + if (!this.isModified('password')) return next(); + try { + const salt = await bcrypt.genSalt(10); + this.password = await bcrypt.hash(this.password, salt); + next(); // Tells Mongoose hashing is done, save the document now + } catch (err) { + next(err); // Safely passes any encryption errors to the database handler + } }); // ✅ password comparison @@ -31,4 +35,4 @@ UserSchema.methods.comparePassword = async function (enteredPassword) { return bcrypt.compare(enteredPassword, this.password); }; -module.exports = mongoose.model("User", UserSchema); \ No newline at end of file +module.exports = mongoose.model("User", UserSchema); diff --git a/src/components/ScrollProgressBar.tsx b/src/components/ScrollProgressBar.tsx index 34e38116..b56ecece 100644 --- a/src/components/ScrollProgressBar.tsx +++ b/src/components/ScrollProgressBar.tsx @@ -61,18 +61,21 @@ const ScrollProgressBar = () => { {/* Scroll progress bar after animation ends */} {!isAnimating && (
- )} + style={{ + position: "fixed", + top: 0, + left: 0, + // Dynamically swaps between full width loading animation and real-time scroll updates + width: isAnimating ? "0" : `${scrollWidth}%`, + height: isAnimating ? "2px" : "3px", + backgroundColor: isAnimating ? "blue" : "#3b82f6", + zIndex: 100, + // Applies the loading animation curve ONLY during the initial loading phase + animation: isAnimating ? "slideIn 2s ease-in-out forwards" : "none", + // Applies smooth tracking ticks once scroll tracking takes over + transition: isAnimating ? "none" : "width 0.1s ease", + }} + /> {/* Animation Keyframes */}