Fix: Safely handle missing session data on redirect#33
Open
ba2slk wants to merge 1 commit intoAzure-Samples:mainfrom
Open
Fix: Safely handle missing session data on redirect#33ba2slk wants to merge 1 commit intoAzure-Samples:mainfrom
ba2slk wants to merge 1 commit intoAzure-Samples:mainfrom
Conversation
Added a guard clause to the `handleRedirect` method to prevent a `TypeError` that occurred when the session data was lost. The previous code would crash the server when it attempted to access `req.session.pkceCodes.verifier` after the redirect, leading to a 'net::ERR_CONNECTION_RESET' error in the browser. The new code checks if the necessary session data is available. If it's missing, it gracefully redirects the user to the home page, allowing them to restart the login flow without causing a server crash.
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.
Purpose
Problem
req.session.pkceCodes.verifierafter the redirect, leading to a 'net::ERR_CONNECTION_RESET' error in the browser.Solution
handleRedirectmethod to prevent aTypeErrorthat occurred when the session data was lost.Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
How to Test
Manual Test
Verify the Fix:
Before the fix, the server would crash with a TypeError after a successful login redirect because req.session.pkceCodes was undefined.
After applying the guard clause, the server should no longer crash. Instead, it should gracefully redirect you to the main page (/), allowing the login flow to complete successfully.
What to Check
Verify that the following are valid:
Other Information