You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
441 B

  1. # frozen_string_literal: true
  2. module Authorization
  3. extend ActiveSupport::Concern
  4. include Pundit::Authorization
  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