New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cases where request is undefined for user passed 'state' checks #698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the if condition either "if (request)" or "if (request && request.state)", but choose one or the other and don't use both in the file.
@@ -371,6 +371,12 @@ export class UserAgentApplication { | |||
// Track login in progress | |||
this.loginInProgress = true; | |||
|
|||
// request can be optional for login calls, hence check for the same | |||
let reqState: string; | |||
if (request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the function parameter be declared as
request?: AuthenticationParameters
instead to indicate that it is valid for it to be undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AE-MS Thanks for reviewing! It is true that making the request parameter optional would allow us to pass it as undefined, which is what we have exposed in the loginRedirect function. However, that doesn't solve the issue of trying to retrieve state from a possibly null request object, which is what the code here does. We will try to find a more elegant solution for this when we perform some refactoring in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AE-MS Updated the login helper functions too to have optional parameters, to clear any confusion extending what @pkanher617 mentioned - "request" is optional only for login() functions but not for acquireToken() calls.
lgtm |
I'm having the same issue today with following error It was working until yesterday but today when we deploy the build to server, starting getting above error. from localhost its still working fine. |
Fix cases where request is undefined for user passed 'state' checks before passing it ServerRequestParameters