London | 25-SDC-July | Ali Qassab | Module Legacy Code | Sprint 1 | Can't log in from profile page #6#41
Conversation
- Redirect users to home page after logout instead of staying on profile page - Resolves 501 error when logging in from profile page after logout - Fixes CodeYourFuture#6
illicitonion
left a comment
There was a problem hiding this comment.
This is a cute workaround, but the core of this bug report is that we're showing a component that doesn't work - if you go to http://localhost:8000/index.html#/profile/AS there's a login component that can never work (if you're not logged in).
Ideally we would make the login component work. If we can't do that, we should hide the component.
There are probably other pages that show a login form when you're not logged in, that don't work - there's probably a common underlying pattern here we need to fix.
|
Thanks for the feedback. I've fixed this.
|
|
The underlying bug looks fixed here, well done! Mixing in the "hide content if you're not logged in", however, seems messy. Deciding to hide profile content if you're not logged in isn't related to the bug being fixed. Importantly, if we do want to hide that profile content:
I'll mark this as complete because the underlying bug has been fixed, but I'd recommend reverting the "if not logged in, hide" changes from this PR. |
|
Oh also, please update your PR description - the "solution" section is no longer accurate :) |
Learners, PR Template
Self checklist
Changelist
Problem:
Users experienced a 501 "Server does not support this operation" error when:
Logging in → clicking a username → logging out → logging back in
Expected to see the profile page but got an error instead
Root Cause:
After logout, users remained on the profile page (#/profile/AS). When logging back in, the application tried to restore this profile page state, which triggered operations that caused the 501 error.
Solution:
Added navigation redirect to the logout function:
function logout() {
state.destroyState();
window.location.hash = "/"; // Redirect to home page
return { success: true };
}