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

Automatically reload updated rights #16308

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

ccailly
Copy link
Member

@ccailly ccailly commented Jan 5, 2024

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets

Description:

This PR introduces a dynamic rights management system, primarily through the addition of a new field last_rights_update in the glpi_profiles table. This field is used to track the last update of the rights associated with a profile. Whenever a right is added, updated, or deleted, this field is updated with the current timestamp. This allows us to easily identify when a profile's rights were last modified and reload them "on the fly" when necessary.

Changes:

  1. Added last_rights_update field to glpi_profiles table in profiles.php migration file and glpi-empty.sql file.
  2. Updated Migration.php to set last_rights_update whenever a right is added, updated, or deleted.
  3. Updated Session.php to reload the current profile if the last_rights_update timestamp is more recent than the one stored in the session.
  4. Added a new method reloadCurrentProfile in Session.php to reload the current profile from the database.
  5. Added a new test testReloadCurrentProfile in Session.php test file to verify the correct functionality of the reloadCurrentProfile method.

@ccailly
Copy link
Member Author

ccailly commented Jan 5, 2024

This PR is a continuation of #16031 and its discussions

src/Session.php Outdated Show resolved Hide resolved
Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

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

Works perfectly 👍(with the suggested changes)

src/Migration.php Outdated Show resolved Hide resolved
src/Session.php Outdated Show resolved Hide resolved
src/Session.php Show resolved Hide resolved
@cedric-anne cedric-anne force-pushed the feature/user-rights-update branch from b576329 to fd46630 Compare January 11, 2024 15:05
Copy link
Member

@cedric-anne cedric-anne left a comment

Choose a reason for hiding this comment

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

  1. Migration class tests should be updated to ensure that last_rights_update field is correctly updated.

  2. The last_rights_update should be updated too when the profile is changed using the Profile::update() method (probably in replacement of the ProfileRight::forceCurrentSessionRights() method). Tests should be added this behaviour too.

@ccailly ccailly force-pushed the feature/user-rights-update branch from bf37bfe to 702d7e9 Compare January 23, 2024 16:01
src/ProfileRight.php Outdated Show resolved Hide resolved
@cedric-anne cedric-anne force-pushed the feature/user-rights-update branch from ca092dd to 68dbdd7 Compare January 24, 2024 12:38
@cedric-anne cedric-anne changed the title feat: Add dynamic rights management Automatically reload updated rights Jan 24, 2024
@cedric-anne cedric-anne merged commit ef93b74 into glpi-project:main Feb 1, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants