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

Allowed permissions in the user factory to be chained #13437

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

marcusmoore
Copy link
Collaborator

Description

This PR allows multiple permissions to be added when chaining off of the user factory.

Previously, trying to apply two permissions in this way:

User::factory()->viewComponents()->viewUsers()->create();

would result in only the second permission, being able to view users, to be applied.

This PR fixes that by calling a new method within all of the permission related factory states of the user model that appends the permission instead of overwrites it.

Type of change

  • New feature (non-breaking change which adds functionality)

@marcusmoore marcusmoore requested a review from snipe as a code owner August 11, 2023 00:02
@what-the-diff
Copy link

what-the-diff bot commented Aug 11, 2023

PR Summary

  • Changes to User Permissions
    The main changes in this PR focus on user permissions. Previously, the value of user permissions was hard-coded. Now, the system uses a new and more flexible approach.

  • Enhancement of User Permission Methods
    Several user methods, like superuser(), admin(), viewAssets(), createAssets(), editAssets(), and canViewReports(), are now leveraging the newly created appendPermission() method. Instead of assigning permissions directly, they add ('append') permissions using this new method, making it easier to edit or update these permissions later on without changing the base code in each of these methods.

  • Introduction of appendPermission() Method
    This is a new function designed to improve flexibility and maintainability of code when dealing with user permissions. It allows developers to easily give or modify the permissions of users by just calling this method and providing the required permission info.

This update enhances the flexibility and scalability of user management. In the future, implementing new features or permissions will be significantly easier and quicker. This update is targeted to improve the overall efficiency and adaptability of our system.

@snipe snipe merged commit ba56746 into snipe:develop Aug 14, 2023
@marcusmoore marcusmoore deleted the feature/improve-user-factory branch August 14, 2023 21:24
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.

2 participants