skill-assessment-app/app/policies/user_policy.rb
2016-09-20 17:19:11 -05:00

26 lines
419 B
Ruby

# frozen_string_literal: true
class UserPolicy < ApplicationPolicy
# User Access Policy
#
# Only Admins can view, create, or update, users
def view?
user.admin? && show?
end
def create?
user.admin?
end
def update?
user.admin?
end
class Scope < Scope
def resolve
return scope if user.admin?
raise Pundit::NotAuthorizedError, "No access to resource."
end
end
end