docbrown/app/controllers/api/v0
Jeremy Friesen a40efc6bbd
Refactoring questions asked of user (#15762)
* Refactoring questions asked of user

In this pull request, I'm extracting and normalizing role-based
questions asked of the user.

Prior to this commit, our codebase has asked two very similar questions
of our user model:

- `user.has_role?(:admin)`
- `user.admin?`

In asking `has_role?(:admin)` we are relying on implementation details
of the rolify gem.  In addition, the `has_role?` question asked
throughout controllers or views means that it's harder to create
hieararchies of permissions.

In favoring `user.admin?` as our question, we can use that indirection
as an opportunity to discuss and decide "Should someone with the
`:super_admin` role be `user.admin? == true`?"

The details of this commit is to do three primary things:

1. Ask the `has_role?` questions in "one place" in the code (e.g. the
   `Authorizer` module)
2. Extract the role based questions that are on the `User` model and
   provde backwards compatable delegation.
3. Structure the code so that it's harder to accidentally call
   `user.has_role?` (e.g., make `User#has_role?` and `User#has_any_role?`
   private).

This is related to #15624 and the updates are informed by discussion in
PR #15691.  This commit supplants #15691.

* Refactoring the liquid tag policy tests

* Fixing typo

* Bump for travis
2021-12-21 12:45:12 -05:00
..
analytics_controller.rb Remove pro role + expose analytics to all users via dashboard (#13156) 2021-03-30 15:02:18 -07:00
api_controller.rb Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
articles_controller.rb Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
comments_controller.rb Profile generalization cleanup phase 2 (#14555) 2021-08-27 09:17:26 +07:00
followers_controller.rb 15 minute fix: Add default argument to JsonApiSortParam (#13369) 2021-04-14 10:32:07 +07:00
follows_controller.rb API: Add route for fetching a user's followed tags (#9108) 2020-09-18 16:28:42 -05:00
health_checks_controller.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
instances_controller.rb Add article and comment count to instance API (#15794) 2021-12-16 13:05:49 -05:00
listings_controller.rb Profile generalization cleanup phase 2 (#14555) 2021-08-27 09:17:26 +07:00
organizations_controller.rb Profile generalization: cleanup (#12947) 2021-08-20 16:36:02 +02:00
podcast_episodes_controller.rb Rubocop: move dot in multi-line calls to leading position (#9262) 2020-07-16 15:51:11 +02:00
profile_images_controller.rb [deploy] Introduce /api/profile_images/:username endpoint (#10547) 2020-10-14 14:24:25 -05:00
readinglist_controller.rb Remove Doorkeeper from API (#15750) 2021-12-16 09:57:26 -06:00
tags_controller.rb Rubocop: move dot in multi-line calls to leading position (#9262) 2020-07-16 15:51:11 +02:00
users_controller.rb Remove Doorkeeper from API (#15750) 2021-12-16 09:57:26 -06:00
videos_controller.rb Return video_source_url in API V0 Videos index (#11040) 2020-11-09 06:27:28 +01:00
webhooks_controller.rb Remove Doorkeeper from API (#15750) 2021-12-16 09:57:26 -06:00