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

upcoming: [M3-7527] - Improve Login History restricted and child user experience #10125

Merged

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Jan 30, 2024

Description πŸ“

Currently, all restricted users receive an unauthorized message (see Before screenshot) after the table data fails to populate when they access the Login History tab. In the case of a child user (user_type: child), who is unrestricted by the API (account_access: read_write), but should be restricted in the UI, we must manually restrict the child user from viewing this page.

This PR updates the child view to not show login history information and display a warning notice to convey unauthorized access. For consistency, we will also make these changes for restricted users.

Note

The API has recently changed from user_type: null to user_type: "default". This is not reflected in this PR at this time because I didn't want to duplicate the work we'll need to make these changes on the front end, which will be done in another ticket.

Changes πŸ”„

  • Provides an informational warning notice to the child user and users with restricted account_access and does not display the login history table.
  • Adds an AccountLogin factory and account/logins endpoint to the MSW so we can now mock that page.
  • Adds integration test spec for the Login History page (account/account-login-history.spec.ts).
  • A couple of aria-label accessibility improvements (account logins table, status icon)

Preview πŸ“·

Before After
Screenshot 2023-11-27 at 12 02 30 PM
Child view Screenshot 2024-02-05 at 4 36 35 PM
Regular restricted user view Screenshot 2024-02-05 at 4 26 39 PM
Added mocks localhost_3000_account_login-history (1)

How to test πŸ§ͺ

Prerequisites

(How to setup test environment)

  • Turn on the Parent/Child feature flag and turn on the mock data.

Reproduction steps

(How to reproduce the issue, if applicable)

  • Have a restricted user that has billing access (the account_access grant) set to either Read-Only or None.
  • Go to http://localhost:3000/account/login-history and observe the table loading and then eventually displaying an "Unauthorized" error.

Verification steps

(How to verify changes)

  • Confirm that child "restricted" users see the warning notice pictured above:
  • Confirm that regular restricted users see the warning notice pictured above:
  • Confirm no regressions to the login history page for a non-restricted user.
  • Confirm integration test passes:
yarn cy:run -s "cypress/e2e/core/account/account-login-history.spec.ts"

As an Author I have considered πŸ€”

Check all that apply

  • πŸ‘€ Doing a self review
  • ❔ Our contribution guidelines
  • 🀏 Splitting feature into small PRs
  • βž• Adding a changeset
  • πŸ§ͺ Providing/Improving test coverage
  • πŸ” Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • πŸ‘£ Providing comprehensive reproduction steps
  • πŸ“‘ Providing or updating our documentation
  • πŸ•› Scheduling a pair reviewing session
  • πŸ“± Providing mobile support
  • β™Ώ Providing accessibility support

@mjac0bs mjac0bs self-assigned this Jan 30, 2024
@mjac0bs mjac0bs changed the title upcoming: [M3 7527] - Child view: Login History upcoming: [M3 7527] - Improve Login History restricted and child user experience Jan 30, 2024
@mjac0bs mjac0bs changed the title upcoming: [M3 7527] - Improve Login History restricted and child user experience upcoming: [M3-7527] - Improve Login History restricted and child user experience Jan 30, 2024
@mjac0bs mjac0bs force-pushed the M3-7527-child-view-account-login-history branch from 4b03619 to c62cb00 Compare February 6, 2024 15:19
@mjac0bs mjac0bs marked this pull request as ready for review February 6, 2024 15:48
@mjac0bs mjac0bs requested review from a team as code owners February 6, 2024 15:48
@mjac0bs mjac0bs requested review from cliu-akamai, cpathipa, hkhalil-akamai and jaalah-akamai and removed request for a team February 6, 2024 15:48
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We didn't have any test coverage for the Login History page, so I added this spec and included some test cases for the changes in this PR.

@@ -41,7 +41,11 @@ const AccountLoginsTableRow = (props: AccountLogin) => {
</TableCell>
</Hidden>
<TableCell statusCell>
<StatusIcon pulse={false} status={accessIconMap[status] ?? 'other'} />
<StatusIcon
ariaLabel={`Status is ${status}`}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an ariaLabel here to make this more accessible and to verify the icon is present in the integration test.

Comment on lines 75 to 77
const isAccountAccessRestricted =
isRestrictedChildUser ||
(profile?.restricted && grants?.global.account_access !== 'read_write');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll display the warning notice for child users and restricted users without account_access.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also getting the unauthorized message for a restricted user with read/write permissions. I'm not sure if it's something particular about my account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @hkhalil-akamai - good catch. After looking into this, I realized that in production, the API will return a 403 Unauthorized for GET account/logins* for any restricted user that tries to access Login History - not just those with restricted account_access. I made an update in f2984f0 to account for that. cc @jaalah-akamai

Before / Prod After
Screenshot 2024-02-08 at 10 34 45 AM Screenshot 2024-02-08 at 10 35 31 AM

Copy link

github-actions bot commented Feb 6, 2024

Coverage Report: βœ…
Base Coverage: 81.09%
Current Coverage: 81.11%

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this test!

Comment on lines 75 to 77
const isAccountAccessRestricted =
isRestrictedChildUser ||
(profile?.restricted && grants?.global.account_access !== 'read_write');
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also getting the unauthorized message for a restricted user with read/write permissions. I'm not sure if it's something particular about my account.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding mocks!

Copy link
Contributor

@jaalah-akamai jaalah-akamai left a comment

Choose a reason for hiding this comment

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

Apart from Hussain's comment, everything else is working as intended.

@mjac0bs mjac0bs added the Add'tl Approval Needed Waiting on another approval! label Feb 8, 2024
Copy link
Contributor

@hkhalil-akamai hkhalil-akamai 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 addressing feedback!

@cpathipa cpathipa added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Feb 9, 2024
@mjac0bs mjac0bs merged commit a53f63b into linode:develop Feb 9, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Parent / Child Account
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants