fix: send real password reset link instead of dummy route - #129
Merged
Conversation
Kanavpreet-Singh
had a problem deploying
to
dockerhub
August 13, 2026 03:40 — with
GitHub Actions
Failure
Collaborator
Author
There was a problem hiding this comment.
Pull request overview
This PR fixes password reset emails by generating a real, usable frontend URL (instead of the previous dummy string) and improves SMTP compatibility by explicitly setting the sender address.
Changes:
- Build password reset links from
verify.base.frontend+ newverify.reset.pathconfig (with a safe default). - Set
Fromfor password reset emails usingspring.mail.username. - Extend
.gitignoreto avoid accidentally committing common credential files.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/main/resources/application.yml |
Adds verify.reset.path config used to build the reset URL. |
src/main/java/com/pecacm/backend/services/EmailService.java |
Constructs real reset links and sets From for reset emails. |
.gitignore |
Ignores local env variants and common credential JSON files. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
59
to
+65
| mailMessage.setSubject("Reset your password"); | ||
| mailMessage.setText( | ||
| "to change your password please click here " + "dummyFrontEndRoute?token=" + token.getToken().toString() | ||
| "Hi,\n\n" | ||
| + "We received a request to reset the password for your PEC ACM account.\n\n" | ||
| + "Reset it here (this link is valid for 15 minutes):\n" | ||
| + buildResetLink(token) + "\n\n" | ||
| + "If you did not request this, you can safely ignore this email.\n" |
Comment on lines
+37
to
+40
| // Gmail requires the sender to match the authenticated account, so the From | ||
| // address is taken from the same property used to log in to the SMTP server. | ||
| @Value("${spring.mail.username}") | ||
| private String fromAddress; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Password reset emails contained the literal string
dummyFrontEndRoute?token=<uuid>instead of a usable link, so no user could ever complete a reset.
verify.base.frontendwas already defined inapplication.ymlbut was read bynothing — the only
@Valuein the whole codebase wasjwt.secret.Changes
EmailServicenow builds the real link fromverify.base.frontendplus a newverify.reset.pathproperty, pointing at the existing frontend route/forgot-password/change-password?token=(seepages/forgot-password/change-password.tsxin the website repo, which already reads
tokenfrom the query string).setFrom. Gmail silently substitutes the authenticatedaccount, which is why nobody noticed; any other SMTP server rejects the message
with
553 5.1.3 The address is not a valid RFC 5321 address. This matters if weever move off Gmail.
existing check in
UserService.changePassword..gitignore: addedsecret.json/serviceAccount*.jsonso credential filescan't be committed by accident.
Config
New property, defaulted in code so existing environments keep working:
Testing
acmcss@pec.edu.inSMTP account; the emailwas delivered and contained
https://pecacm.in/forgot-password/change-password?token=<uuid>.www.pecacm.in, token preserved).single-use, 15-minute expiry, cross-user token rejected 401, unknown email 404,
blank password 400, password actually changes and the old one stops working.
Not in this PR
repository/auth.tsstill stubssendResetEmailandchangePassword— they return "This feature is still under testing" and nevercall the backend. The feature is not user-complete until that is implemented.
POST /v1/user/forgot-passwordstill requires ausernamequery param, but thefrontend reset page only has the token and the new password. Worth deciding
separately whether the backend should derive the user from the token.