-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We need to fix delegatable permissions, and this will involve changes to the `UserApplicationPermissionPolicy`. Currently everything is based on the `signin` permission. This undoes that, updates the `UserApplicationPermission.for` method so that `supported_permission` is compulsory, and - for now - passes in the `signin` permission where this is used. This will be iterated on in later commits to gradually fix delagatable permissions This required an update to the `UserApplicationPermissionPolicy` tests, and I restructured them in the process
- Loading branch information
Showing
7 changed files
with
84 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
class UserApplicationPermissionPolicy < BasePolicy | ||
def create? | ||
return false unless Pundit.policy(current_user, user).edit? | ||
|
||
return true if current_user.govuk_admin? | ||
|
||
current_user.publishing_manager? && current_user.has_access_to?(application) && application.signin_permission.delegatable? | ||
current_user.publishing_manager? && current_user.has_access_to?(application) && supported_permission.delegatable? | ||
end | ||
alias_method :destroy?, :create? | ||
alias_method :delete?, :create? | ||
alias_method :update?, :create? | ||
alias_method :edit?, :create? | ||
|
||
delegate :user, :application, to: :record | ||
delegate :user, :application, :supported_permission, to: :record | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters