diff --git a/app/policies/api/v0/template_policy.rb b/app/policies/api/v0/template_policy.rb new file mode 100644 index 0000000..7ec770b --- /dev/null +++ b/app/policies/api/v0/template_policy.rb @@ -0,0 +1,23 @@ +module Api + module V0 + class TemplatePolicy < ApplicationPolicy + attr_reader :user, :template + + def initialize(user, template) + raise Pundit::NotAuthorizedError, _("must be logged in") unless user + unless user.org.token_permission_types.include? TokenPermissionType::TEMPLATES + raise Pundit::NotAuthorizedError, _("must have access to guidances api") + end + @user = user + @template = template + end + + ## + # always allowed as index chooses which guidances to display + def index? + true + end + + end + end +end \ No newline at end of file