This guide explains how the password reset system works in Campus Bridge and the changes that have been made to ensure security and proper functionality.
The password reset system follows these steps:
- User clicks "Forgot Password" link on login page
- User enters their email address
- System checks if email exists in database
- System generates secure reset token and expiration time (1 hour)
- System stores token in database
- System sends reset email to user's email address
- User clicks reset link in email
- User enters new password
- System validates token and updates password
- System clears reset token from database
I've made several important security improvements:
The system no longer displays reset links directly in the browser. All reset links are sent exclusively via email.
Regardless of whether an email exists in the system or whether email is configured, users receive the same generic message:
"If an account exists with that email, a password reset link has been sent."
This prevents attackers from determining which emails exist in the system.
The system uses crypto.randomBytes(32).toString('hex') to generate cryptographically secure reset tokens.
Reset tokens automatically expire after 1 hour for security.
- System sends password reset email to user's email address
- User receives email with reset link
- User clicks link to reset password
- System generates reset token and stores it in database
- System returns generic success message to user
- No reset link is displayed in browser
- Admin can manually provide reset link if needed
- System still generates and stores reset token
- System returns generic success message to user
- No reset link is displayed in browser
- Admin can manually provide reset link if needed
If you need to manually generate a reset link for a user (for testing or support):
Format:
http://yourdomain.com/reset-password.html?token=TOKEN&email=USER_EMAIL
To get the token from the database:
SELECT reset_token, email FROM users WHERE email = 'user@example.com' AND reset_token IS NOT NULL AND reset_token_expires > NOW();- Check that all environment variables are correctly set in .env
- Verify that your email credentials are correct
- Ensure that your email provider allows SMTP access
- Check the server console for error messages
- Verify that the user's email exists in the database
- Check that the reset token hasn't expired (1-hour limit)
- Ensure the user is clicking the complete reset link
- Never commit your .env file to version control
- Use App Passwords instead of regular passwords for email services
- Regularly monitor password reset attempts for suspicious activity
- Consider implementing rate limiting for password reset requests
- Navigate to the login page
- Click "Forgot Password"
- Enter a valid email address
- Check that you receive the generic success message
- If email is configured, check your email for the reset link
- Click the reset link and set a new password
- Verify you can log in with the new password