Skip to content
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

refactor: removing code for validating non null getAuthenticatedUser function #683

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

himan085
Copy link
Contributor

@himan085 himan085 commented Jan 16, 2024

Discussion: #680

When PDK generates code for the frontend React website, it checks if the function getAuthenticatedUser is defined or not: code pointer
This function is fetched from the context and used inside useEffect as shown below:

const { getAuthenticatedUser } = useCognitoAuthContext();

  useEffect(() => {
    if (getAuthenticatedUser) {
      const authUser = getAuthenticatedUser();
      // code doing stuff using authUser
    }
  }, [getAuthenticatedUser, setUsername, setEmail]);

After this PR in aws-northstar this check is no longer required since the getAuthenticatedUser has a default state for the CognitoAuthContext which defines the getAuthenticatedUser method: code pointer

Removing the non-null check for getAuthenticatedUser function definition at all places in this PR.

…r getAuthenticatedUser in Cognito authentication code for React website
@himan085 himan085 changed the title Removing redundant code for validating non null getAuthenticatedUser function refactor: removing code for validating non null getAuthenticatedUser function Jan 16, 2024
Copy link
Contributor

@agdimech agdimech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing :)

@agdimech agdimech merged commit 43c0d6d into aws:mainline Jan 17, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants