1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

basic access to members management for managers

This commit is contained in:
Sylvain 2020-04-27 17:48:13 +02:00
parent 8c610ea336
commit 102709246f
6 changed files with 25 additions and 17 deletions

View File

@ -222,7 +222,7 @@ class API::MembersController < API::ApiController
],
statistic_profile_attributes: %i[id gender birthday])
elsif current_user.admin?
elsif current_user.admin? || current_user.manager?
params.require(:user).permit(:username, :email, :password, :password_confirmation, :is_allow_contact, :is_allow_newsletter, :group_id,
tag_ids: [],
profile_attributes: [:id, :first_name, :last_name, :phone, :interest, :software_mastered, :website, :job,

View File

@ -6,7 +6,9 @@ class API::UsersController < API::ApiController
before_action :set_user, only: %i[destroy]
def index
if current_user.admin? && %w[partner manager].include?(params[:role])
authorize User
if %w[partner manager].include?(params[:role])
@users = User.with_role(params[:role].to_sym).includes(:profile)
else
head 403

View File

@ -1,6 +1,6 @@
class AdminPolicy < ApplicationPolicy
def index?
user.admin?
user.admin? || user.manager?
end
def create?

View File

@ -2,9 +2,13 @@
# Check the access policies for API::AvailabilitiesController
class AvailabilityPolicy < ApplicationPolicy
%w[index? show? create? update? destroy? reservations? export? lock?].each do |action|
%w[index? show? create? update? destroy? reservations? lock?].each do |action|
define_method action do
user.admin? || user.manager?
end
end
def export?
user.admin?
end
end

View File

@ -16,26 +16,30 @@ class UserPolicy < ApplicationPolicy
end
def show?
user.admin? || (record.is_allow_contact && record.member?) || (user.id == record.id)
user.admin? || user.manager? || (record.is_allow_contact && record.member?) || (user.id == record.id)
end
def update?
user.admin? || (user.id == record.id)
user.admin? || user.manager? || (user.id == record.id)
end
def destroy?
user.admin? || (user.id == record.id)
end
def merge?
user.id == record.id
%w[merge complete_tour].each do |action|
define_method "#{action}?" do
user.id == record.id
end
end
def complete_tour?
user.id == record.id
%w[list index].each do |action|
define_method "#{action}?" do
user.admin? || user.manager?
end
end
%w[list create mapping].each do |action|
%w[create mapping].each do |action|
define_method "#{action}?" do
user.admin?
end

View File

@ -2,12 +2,10 @@
# Check the access policies for API::WalletController
class WalletPolicy < ApplicationPolicy
def by_user?
user.admin? || user.manager? || user == record.user
end
def transactions?
user.admin? || user == record.user
%w[by_user transactions].each do |action|
define_method "#{action}?" do
user.admin? || user.manager? || user == record.user
end
end
def credit?