diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-07-05 02:41:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-05 02:41:40 +0200 |
commit | 44b2ee3485ba0845e5910cefcb4b1e2f84f34470 (patch) | |
tree | cc91189c9b36aaf0a04d339455c6d238992753a9 /app/controllers/api/v2 | |
parent | 1b4054256f9d3302b44f71627a23bb0902578867 (diff) |
Add customizable user roles (#18641)
* Add customizable user roles * Various fixes and improvements * Add migration for old settings and fix tootctl role management
Diffstat (limited to 'app/controllers/api/v2')
-rw-r--r-- | app/controllers/api/v2/admin/accounts_controller.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/controllers/api/v2/admin/accounts_controller.rb b/app/controllers/api/v2/admin/accounts_controller.rb index a89e6835e..bcc1a0733 100644 --- a/app/controllers/api/v2/admin/accounts_controller.rb +++ b/app/controllers/api/v2/admin/accounts_controller.rb @@ -11,6 +11,7 @@ class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController email ip invited_by + role_ids ).freeze PAGINATION_PARAMS = (%i(limit) + FILTER_PARAMS).freeze @@ -18,7 +19,17 @@ class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController private def filtered_accounts - AccountFilter.new(filter_params).results + AccountFilter.new(translated_filter_params).results + end + + def translated_filter_params + translated_params = filter_params.slice(*AccountFilter::KEYS) + + if params[:permissions] == 'staff' + translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id) + end + + translated_params end def filter_params |