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

[$250] Upgrade - Invited user can access upgrade page via /upgrade/report-fields path #47904

Closed
6 tasks done
IuliiaHerets opened this issue Aug 23, 2024 · 25 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Aug 23, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.0.24-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  • User is invited to workspace.
  • Steps below will be performed by the invited user.
  1. Go to staging.new.expensify.com
  2. Go to the invited workspace settings.
  3. Add /upgrade/report-fields to the URL (eg, staging.new.expensify.com/settings/workspaces/ID/upgrade/report-fields).

Expected Result:

Not here page will open because the invited user should not be able to access or upgrade the workspace.

Actual Result:

Upgrade page opens although the workspace cannot be upgraded by the invited user.

Workaround:

Unknown

Platforms:

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6580087_1724397892801.20240823_152130.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01819a1e2aa1e41f2a
  • Upwork Job ID: 1828745121652626422
  • Last Price Increase: 2024-08-28
  • Automatic offers:
    • paultsimura | Reviewer | 103720683
Issue OwnerCurrent Issue Owner: @paultsimura
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 23, 2024
Copy link

melvin-bot bot commented Aug 23, 2024

Triggered auto assignment to @dylanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@IuliiaHerets
Copy link
Author

We think that this bug might be related to #wave-control

@IuliiaHerets
Copy link
Author

@dylanexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@excile1
Copy link

excile1 commented Aug 23, 2024

Edited by proposal-police: This proposal was edited at 2024-08-23T11:20:13Z.

Proposal

Please re-state the problem that we are trying to solve in this issue.

The invited user, who is not an admin, is able to access the upgrade page.

What is the root cause of that problem?

The root cause of this problem is this check in WorkspaceUpgradePage.tsx:

if (!feature || !policy) {
return <NotFoundPage />;
}

which only returns the not found page if the policy or feature doesn't exist.

What changes do you think we should make in order to solve the problem?

Updating this check to be something like:
if (!feature || !policy || !PolicyUtils.isPolicyAdmin(policy)) {
should fix the issue, and it will only allow the workspace administrator to access the upgrade page.
To make sure the upgrade doesn't fire, probably also worth updating that same check in the upgradeToCorporate function:

const upgradeToCorporate = () => {
if (!policy || !feature) {
return;
}
Policy.upgradeToCorporate(policy.id, feature.name);
};

What alternative solutions did you explore? (Optional)

An alternative solution I explored was wrapping the page with the AccessOrNotFoundWrapper component, while specifying the accessVariants parameter as CONST.POLICY.ACCESS_VARIANTS.ADMIN. This also works, but I believe my initial solution is a little bit cleaner and produces the same result.

Result:
(invited user)
Screenshot 2024-08-23 at 11 19 44

(workspace admin)
Screenshot 2024-08-23 at 11 20 13

@mkzie2
Copy link
Contributor

mkzie2 commented Aug 23, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Upgrade page opens although the workspace cannot be upgraded by the invited user.

What is the root cause of that problem?

We only display the not found page if the feature or policy is empty. For the invited user, the policy isn't empty which leads the user with role is user still can access the upgrade page via deep link.

if (!feature || !policy) {
return <NotFoundPage />;
}

What changes do you think we should make in order to solve the problem?

We should only show this page for the admin of the policy and we also need to prevent calling the API from confirmUpgrade function here If the member user accesses the upgrade page of the control policy and closes this page.

To cleaner we can create a variable that checks whether the not found page should show or not

shouldShowNotFoundPage = !feature  || !policy || !PolicyUtils.isPolicyAdmin(policy)

And use this variable to show the not found page here and prevent calling confirmUpgrade function here

if (!isUpgraded || shouldShowNotFoundPage) {
    return;
}
confirmUpgrade();

What alternative solutions did you explore? (Optional)

For the case showing not found page, we can use AccessOrNotFoundWrapper as we did on WorkspaceMoreFeaturesPage here

@excile1
Copy link

excile1 commented Aug 23, 2024

Proposal

Updated

@melvin-bot melvin-bot bot added the Overdue label Aug 26, 2024
Copy link

melvin-bot bot commented Aug 26, 2024

@dylanexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@dylanexpensify dylanexpensify added the External Added to denote the issue can be worked on by a contributor label Aug 28, 2024
Copy link

melvin-bot bot commented Aug 28, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01819a1e2aa1e41f2a

@melvin-bot melvin-bot bot changed the title Upgrade - Invited user can access upgrade page via /upgrade/report-fields path [$250] Upgrade - Invited user can access upgrade page via /upgrade/report-fields path Aug 28, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 28, 2024
Copy link

melvin-bot bot commented Aug 28, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @paultsimura (External)

@melvin-bot melvin-bot bot removed the Overdue label Aug 28, 2024
@paultsimura
Copy link
Contributor

paultsimura commented Aug 28, 2024

Thanks for the proposals. @mkzie2's proposal was the first to include the access check inside the functions, which is vital for this case. Therefore, we should proceed with it.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Aug 28, 2024

Triggered auto assignment to @tgolen, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 28, 2024
Copy link

melvin-bot bot commented Aug 28, 2024

📣 @paultsimura 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Aug 28, 2024

📣 @mkzie2 You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 29, 2024
@paultsimura
Copy link
Contributor

Deployed to production: #48256 (comment)
Payment is due on Sep 10.

@paultsimura
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: fix: redirect to proper place after upgrade #46617
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: https://github.com/Expensify/App/pull/46617/files#r1748934169
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • Determine if we should create a regression test for this bug: Yes
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression Test Proposal

  1. Login as a workspace's invited user (neither admin nor auditor)
  2. Go to the Workspace Upgrade page by entering the URL: /settings/workspaces/:workspaceID/upgrade/report-fields
  3. Verify the "Not found" page is shown

Do we agree 👍 or 👎

@dylanexpensify
Copy link
Contributor

Payment summary:

Contributor: @mkzie2 $250
Contributor+: @paultsimura $250

Please apply/request!

@dylanexpensify
Copy link
Contributor

@mkzie2 please apply here!!

@dylanexpensify
Copy link
Contributor

bump @mkzie2 !

@mkzie2
Copy link
Contributor

mkzie2 commented Sep 18, 2024

@dylanexpensify Sorry for missing this. Could you help send an offer to my account at https://www.upwork.com/freelancers/~019f73367b03c6d784 ?

@dylanexpensify
Copy link
Contributor

dylanexpensify commented Sep 27, 2024

Ah all good! Invite sent @mkzie2!!

@mkzie2
Copy link
Contributor

mkzie2 commented Sep 27, 2024

@dylanexpensify Thank you, I accepted the invite

@melvin-bot melvin-bot bot removed the Weekly KSv2 label Oct 1, 2024
Copy link

melvin-bot bot commented Oct 1, 2024

This issue has not been updated in over 15 days. @tgolen, @paultsimura, @dylanexpensify, @mkzie2 eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@melvin-bot melvin-bot bot added the Monthly KSv2 label Oct 1, 2024
@paultsimura
Copy link
Contributor

@dylanexpensify can we close this one?

@dylanexpensify
Copy link
Contributor

@mkzie2 pending offer accepting

@mkzie2
Copy link
Contributor

mkzie2 commented Oct 7, 2024

@dylanexpensify Hey thanks! I accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

6 participants