logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

authorization.rb (426B)


  1. # frozen_string_literal: true
  2. module Authorization
  3. extend ActiveSupport::Concern
  4. include Pundit
  5. def pundit_user
  6. current_account
  7. end
  8. def authorize(*)
  9. super
  10. rescue Pundit::NotAuthorizedError
  11. raise Mastodon::NotPermittedError
  12. end
  13. def authorize_with(user, record, query)
  14. Pundit.authorize(user, record, query)
  15. rescue Pundit::NotAuthorizedError
  16. raise Mastodon::NotPermittedError
  17. end
  18. end