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

Prevent CARE from reloading during sign in/out πŸƒβ€β™‚οΈ #6828

Merged
merged 6 commits into from
Dec 13, 2023

Conversation

rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Dec 8, 2023

WHAT

πŸ€–[deprecated] Generated by Copilot at f64151f

Refactored authentication and sign out logic to use the useAuthContext hook and the AuthUserProvider component. Simplified and cleaned up code in various components and files related to authentication. Fixed minor typos and bugs.

Proposed Changes

@coronasafe/care-fe-code-reviewers @coronasafe/code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

HOW

πŸ€–[deprecated] Generated by Copilot at f64151f

  • Refactor the Login component to use the useAuthContext hook and the signIn function from the context (link,link)
  • Refactor the signOut logic to be handled by the AuthUserProvider component, and use the useAuthContext hook and the signOut function from the context in the SidebarUserCard, SessionExpired, and UserProfile components (link,link,link,link,link,link,link,link)
  • Refactor the AuthUserProvider component to use the useCallback hook to create the signIn and signOut functions, and pass them to the AuthUserContext along with the user value (link,link,link)
  • Add the getRedirectURL and getRedirectOr helper functions to the AuthUserProvider component file, to handle the redirection logic after signIn and signOut based on the redirect query parameter (link)
  • Add the storage event listener to the AuthUserProvider component, to handle the sign out from another tab by calling the signOut function if the tokens are removed from the local storage (link)
  • Export the JwtTokenObtainPair and LoginCredentials interfaces from the src/Redux/api.tsx file, and use them to type the response and the input of the routes.login endpoint (link,link)
  • Rename the LoginInput interface to LoginCredentials for consistency with the signIn function (link)
  • Change the type of the refresh property of the TBody property of the routes.tokenRefresh object to use the refresh property of the JwtTokenObtainPair interface (link)
  • Use the nullish coalescing operator (??) instead of the logical OR operator (||) to set the silent property of the merged request options, to avoid overriding the silent property if it is explicitly set to false in the overrides (link)
  • Use the formatName function from the src/Utils/utils.ts file to display the user's name in the SidebarUserCard component, instead of concatenating the first and last name manually (link)
  • Correct the comment in the Login component to use the term "unmounted" instead of "dismounted" (link)
  • Remove the unused imports and functions from the src/Routers/AppRouter.tsx and src/Utils/utils.ts files (link,link,link,link)

@rithviknishad rithviknishad requested a review from Ashesh3 December 8, 2023 17:39
@rithviknishad rithviknishad requested a review from a team as a code owner December 8, 2023 17:39
Copy link

vercel bot commented Dec 8, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
care-storybook βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Dec 13, 2023 8:10am

Copy link

netlify bot commented Dec 8, 2023

βœ… Deploy Preview for care-egov-staging ready!

Name Link
πŸ”¨ Latest commit 0661c11
πŸ” Latest deploy log https://app.netlify.com/sites/care-egov-staging/deploys/657966d310b079000856ff77
😎 Deploy Preview https://deploy-preview-6828--care-egov-staging.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

πŸ‘‹ Hi, @rithviknishad,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 13, 2023
@rithviknishad rithviknishad removed the merge conflict pull requests with merge conflict label Dec 13, 2023
src/Utils/utils.ts Outdated Show resolved Hide resolved
src/Utils/utils.ts Outdated Show resolved Hide resolved
src/Utils/utils.ts Outdated Show resolved Hide resolved
src/Utils/utils.ts Outdated Show resolved Hide resolved
@nihal467
Copy link
Member

LGTM

@khavinshankar khavinshankar merged commit 27c5766 into develop Dec 13, 2023
27 of 37 checks passed
Copy link

@rithviknishad We truly appreciate your efforts. Thank you for taking the time to contribute; this is a very valuable contribution to us πŸ₯‡. We always welcome your contribution πŸ™‚, so feel free to contribute to anything anytime, and never lose that spirit of innovation πŸ™Œ.

@khavinshankar khavinshankar deleted the improve-login-flow branch December 13, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Care app reloads upon login
4 participants