West Midlands | 26 March SDC | Iswat Bello | Sprint 1 | Purple Forest/bug report/Can't log in from profile page#209
Conversation
Add comprehensive ignore rules for the project: - Python virtual environments (.venv/, venv/, ENV/) - Python cache files (__pycache__/, *.pyc) - Database data directory (db/pg_data/) - Environment configuration files (.env) - IDE and OS-specific files (.vscode/, .DS_Store)
Prevent login form from falling back to native POST by binding the submit handler to the form element instead of a link click. This ensures preventDefault() is called on form submission. - Profile view now listens to [data-form='login'] submit event - Previously incorrectly bound to [data-action='login'] click
nedssoft
left a comment
There was a problem hiding this comment.
Iswat, this is a genuinely excellent bug report — one of the clearest I've seen at Sprint 1. 👏 Diagnosing it by comparing the working home.mjs against the broken profile.mjs, spotting submit-on-form vs click-on-button, and connecting that to why preventDefault() wasn't firing (so the browser did its default POST to :8080 instead of the API on :3000) — that's exactly how you hunt a bug. The fix matches the pattern that already works, and you verified it properly. Lovely work.
One thing to think about for future PRs (not a change I need here): alongside the login fix you also added several .gitignore entries. Ignoring .env and the database is a great instinct! 👍 But when you're fixing one specific bug, do you think a reviewer prefers unrelated changes bundled in, or the PR kept focused on just the bug (with the .gitignore tidy-up as its own small PR)? Worth keeping in mind as your changelists grow.
Thank you so much @nedssoft for the feedback! I’m really glad the logic in the report was clear. Regarding the |
Learners, PR Template
Self checklist
Changelist
This PR fixes a bug where logging in from a profile page resulted in a 501 Error. The issue was caused by an incorrect event listener in the profile.mjs view. By changing the listener to target the form's submit event instead of a button's click event, the application now correctly prevents the default browser behavior and sends the login request to the Backend API (Port 3000) instead of the Frontend server (Port 8080).
1. The Problem
Users were unable to log back in if they logged out while viewing a profile page. Instead of a successful login, the application showed a 501 Error: Server does not support this operation.
2. Reproduction Steps
To confirm the bug, I performed the following steps:
sample/sosecret./#/profile/AS).sample.POSTrequest error 501. The Backend terminal (Port 3000) showed no activity, meaning the login request was being sent to the wrong building.3. The Discovery
I compared
frontend/views/home.mjs(where login works) withfrontend/views/profile.mjs(where it fails).home.mjswas correctly listening for asubmitevent on the login form.profile.mjswas listening for aclickevent on the login button.event.preventDefault()in the login handler wasn't working correctly. This caused the browser to perform a "Default HTML Submission" to the Frontend server instead of using theapiService.4. The Fix
I updated the event listener logic in
frontend/views/profile.mjs:[data-action='login'](the button) to[data-form='login'](the form).clicktosubmit.5. Final Verification
After applying the fix, I repeated the reproduction steps. I confirmed that:
POSTrequest is now correctly going to the Backend (Port 3000).