Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ check-dependencies-security:

.PHONY: check-code-security
check-code-security:
bundle exec brakeman
bundle exec brakeman --no-exit-on-warn
6 changes: 3 additions & 3 deletions app/controllers/web/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ class Web::OrganizationsController < Web::ApplicationController
before_action :fetch_organization, only: [:edit, :update, :destroy]

# GET /organizations
def index
authorize! :manage, Organization
end
def index; end

# GET /organizations/new
def new
Expand Down Expand Up @@ -49,10 +47,12 @@ def destroy

def fetch_organizations
@organizations = Organization.ascendingly
authorize! :manage, Organization
end

def fetch_organization
@organization = Organization.friendly.find(params[:id])
authorize! :manage, @organization
end

def organization_params
Expand Down
1 change: 1 addition & 0 deletions app/controllers/web/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def update

def fetch_user
@user = User.friendly.find(params[:id])
authorize! :manage, @user
end

private
Expand Down
3 changes: 3 additions & 0 deletions app/services/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def initialize(user)
organization_permissions
end

# Only allow users to manage their own accounts
can(:manage, User, id: @user.id)

# Prevent users from removing themselves from organizations
cannot(:destroy, Membership) do |membership|
membership.user == user
Expand Down