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

DCJ-668: Bug Fixes for Terms of Service Acceptance #2671

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

rushtong
Copy link
Contributor

@rushtong rushtong commented Sep 11, 2024

Addresses

https://broadworkbench.atlassian.net/browse/DCJ-668

Summary

#2657 introduced a couple of regressions that this PR fixes.

  1. Don't sign out when oidc user is not present - it won't be until we have oidc sign-in
  2. Don't sign out if the user has authenticated, but hasn't accepted ToS
  3. Re-order the tos checks to help simplify the process
  4. Lint the Sign-in component

Suggested that you hide whitespace changes due to the large number of lint fixes.


Have you read Terra's Contributing Guide lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@@ -118,13 +128,6 @@ export const SignInButton = (props: SignInButtonProps) => {

const shouldRedirectTo = (page: string): boolean => page !== '/' && page !== '/home';

const attemptSignInCheckToSAndRedirect = async (redirectTo:string, shouldRedirect: boolean) => {
await checkToSAndRedirect(shouldRedirect ? redirectTo : null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this line to onSuccess to simplify the logic checks

Comment on lines -123 to -125
Metrics.identify(Storage.getAnonymousId());
Metrics.syncProfile();
Metrics.captureEvent(eventList.userSignIn);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved these to checkToSAndRedirect in the place where we know the user is authenticated and accepted ToS.

Comment on lines -85 to +90
await Auth.signOut();
// User has authenticated, but has not accepted ToS
Storage.setUserIsLogged(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix that allows for an authenticated user to access /tos_acceptance

Comment on lines -27 to -31
if (oidcUser !== null) {
Storage.setUserIsLogged(true);
} else {
await Auth.signOut();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fix allows for page refreshes without signing out the user.

@rushtong rushtong marked this pull request as ready for review September 11, 2024 19:53
@rushtong rushtong requested a review from a team as a code owner September 11, 2024 19:53
@rushtong rushtong requested review from fboulnois and removed request for a team September 11, 2024 19:53
Copy link
Contributor

@fboulnois fboulnois left a comment

Choose a reason for hiding this comment

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

looks good 👍

Copy link
Contributor

@rjohanek rjohanek left a comment

Choose a reason for hiding this comment

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

changes look good

@rushtong rushtong merged commit fb6e4c3 into develop Sep 13, 2024
9 checks passed
@rushtong rushtong deleted the gr-DCJ-668-ToS-fixes branch September 13, 2024 20:41
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.

4 participants