-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mise en place de pundit pour le super_admin et ajout du role support (#…
…3918) * initial pundit for administrate and policies for super_admin * remove unused files and sign_in_as user method * change for #3788 * Update SuperAdmin role and Pundit configuration * Update policies for support and super_admin behavior * use administrate custom behavior for redirect after destroy * fix links for delete agent and good_job, avoid privilége escalation * add rule for anonymizer * refacto shared_policy_example * policies spec for super_admin * apply Victors suggestion : rename super_admin role in legacy_admin and minor policy changes
- Loading branch information
Showing
69 changed files
with
730 additions
and
468 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 was deleted.
Oops, something went wrong.
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,13 +1,7 @@ | ||
module SuperAdmins | ||
class AgentRolesController < SuperAdmins::ApplicationController | ||
def destroy | ||
if requested_resource.destroy | ||
flash[:notice] = translate_with_resource("destroy.success") | ||
else | ||
flash[:error] = requested_resource.errors.full_messages.join("<br/>") | ||
end | ||
|
||
redirect_to(after_resource_created_path(requested_resource.agent), notice: flash[:notice]) | ||
def after_resource_destroyed_path(requested_resource) | ||
[namespace, requested_resource.agent] | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module SuperAdmins | ||
class AgentServicesController < SuperAdmins::ApplicationController | ||
def after_resource_destroyed_path(requested_resource) | ||
[namespace, requested_resource.agent] | ||
end | ||
end | ||
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
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,21 +1,4 @@ | ||
module SuperAdmins | ||
class MotifsController < SuperAdmins::ApplicationController | ||
# To customize the behavior of this controller, | ||
# you can overwrite any of the RESTful actions. For example: | ||
# | ||
# def index | ||
# super | ||
# @resources = Agent. | ||
# page(params[:page]). | ||
# per(10) | ||
# end | ||
|
||
# Define a custom finder by overriding the `find_resource` method: | ||
# def find_resource(param) | ||
# Agent.find_by!(slug: param) | ||
# end | ||
|
||
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions | ||
# for more information | ||
end | ||
end |
21 changes: 0 additions & 21 deletions
21
app/controllers/super_admins/plage_ouvertures_controller.rb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,21 +1,20 @@ | ||
module SuperAdmins | ||
class SuperAdminsController < SuperAdmins::ApplicationController | ||
# To customize the behavior of this controller, | ||
# you can overwrite any of the RESTful actions. For example: | ||
# | ||
# def index | ||
# super | ||
# @resources = SuperAdmin. | ||
# page(params[:page]). | ||
# per(10) | ||
# end | ||
before_action :check_privilege_escalation, only: %i[update] | ||
|
||
# Define a custom finder by overriding the `find_resource` method: | ||
# def find_resource(param) | ||
# SuperAdmin.find_by!(slug: param) | ||
# end | ||
def check_privilege_escalation | ||
return not_authorized_to_update if privilege_escalation? | ||
end | ||
|
||
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions | ||
# for more information | ||
private | ||
|
||
def not_authorized_to_update | ||
flash[:error] = "Vous n'êtes pas autorisé à modifier le role de super_admin" | ||
redirect_to(request.referer) | ||
end | ||
|
||
def privilege_escalation? | ||
current_super_admin.support_member? && resource_params[:role] == "super_admin" | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module SuperAdmins | ||
class UserProfilesController < SuperAdmins::ApplicationController | ||
def after_resource_destroyed_path(requested_resource) | ||
[namespace, requested_resource.user] | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,4 @@ | ||
module SuperAdmins | ||
class UsersController < SuperAdmins::ApplicationController | ||
def sign_in_as | ||
user = User.find(params[:id]) | ||
if sign_in_as_allowed? | ||
sign_out(:agent) | ||
sign_in(:user, user, bypass: true) | ||
redirect_to root_url | ||
else | ||
flash[:error] = "Fonctionnalité désactivée sur cet environnement." | ||
redirect_to super_admins_user_path(user) | ||
end | ||
end | ||
end | ||
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
Oops, something went wrong.