-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
First fix for user FMCS scoping #14591
Conversation
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
PR Summary
|
This has broken a few of our automated tests - trying to determine why now. |
Signed-off-by: snipe <[email protected]>
Test results are spot on so far. |
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
@bzeus - are you also testing the API or just the GUI? |
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
…-ed things Signed-off-by: snipe <[email protected]>
@bzeus can you test again - I just pushed through some changes @marcusmoore - can you take a look at the tests I added and make sure I'm not doing anything too crazy? |
Signed-off-by: snipe <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests look good 👍🏾
One minor suggestion on clarity.
Side note: it's best practice to only run one request per test case but I'm guilty of doing exactly what you did here without issue so
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
I know, I get it. :( But the build up and tear down would be identical if I made them separate tests, so... damned if you do, damned if you duplicate a bunch of code. :( |
Tests are on point, works as it should. |
This corrects some of the scoping we were doing around users for exporting lists, editing, etc and adds a lot more info around FMCS in the code (because it's always miserable to try to detangle that hot mess.)
We cannot use the standard CompanyableTrait that we use everywhere else on the user model because it's a global scope, and that causes an infinite loop by Laravel as it tries to add that scope onto the user model of the currently logged in user, in addition to the users listings/view/etc. This took me way too long to remember, but it explains why we handle the scoping on the User model slightly differently.
I also moved the scoping methods in the Company model to the bottom of the file, to keep it consistent with the way we handle query scopes elsewhere.
I'd like to continue working on a better way to handle this so that we get the same benefits of the CompanyableTrait without all the complex manual query scoping we have to do for the User model now, but this solves the immediate issue.
How to test:
Create a company, "Brand Spankin New", and three users:
spankinadmin1
(admin with "Brand Spankin New" as their company)nospankadmin2
(admin without any company)spankuser1
(regular user with "Brand Spankin New" as their company)spankin
asset (asset belonging to "Brand Spankin New")Easiest way to test this is using three browsers so you have three different sessions. Make sure you have Full Multiple Company Support enabled.
spankinadmin1
:spankinadmin1
- can only see all of the assets and users within "Brand Spankin New"/users/{:id}
to a user you know doesn't belong to "Brand Spankin New", you should get kicked back with a not found error.nospankadmin2
:spankinadmin1
- can only see all of the assets and users without a company assigned/users/{:id}
to a user you know does have a company association, you should get kicked back with a not found error.Regular superadmins should of course have access to everything they would normally have access to.
Fixes #14539, Fixes [sc-25183], [sc-25258]