discourse/spec
benj 72e4e53fda
FEATURE: add option to hide IP addresses from moderators (#33682)
# Hide IP Addresses from Moderators When `moderators_view_ips` is
Disabled

## Summary 
Feature Request Link -
https://meta.discourse.org/t/option-to-hide-ip-addresses-from-moderators/207715/51
This PR implements a feature to **hide IP addresses from moderators**
when the `moderators_view_ips` site setting is disabled. Previously,
moderators could view IPs in multiple locations across the admin UI.
This update ensures that IP addresses are visible to moderators when the
setting allows it.

## Changes Implemented  

### Backend Updates
- **Added `moderators_view_ips` site setting** in `site_settings.yml`
- **Updated `CurrentUserSerializer`** to include `can_see_ip` field
based on the user’s role and site setting.
- **Modified `AdminUserSerializer`** to restrict IP address visibility.
- **Updated `UsersController`** to prevent IP addresses from being
included in API responses.
- **Restricted IPs in `ScreenedIpAddressesController`** by throwing
`Discourse::InvalidAccess` if the user lacks permission.

### Frontend Updates
- **Hid "Screened IPs" tab** in `/admin/logs` when `moderators_view_ips`
is disabled.
- **Blocked direct access to `/admin/logs/screened_ip_addresses`** for
unauthorized users.
- **Updated `user-index.hbs` and `logs.hbs`** to conditionally hide IP
fields.

### UI Screenshots

New option for Admins in the Admin Security settings dashboard:
![Screenshot 2025-02-21 at 5 32
00 PM](https://github.com/user-attachments/assets/5b315434-7724-4cb9-a3dc-d88750df00a6)


Moderator's view before:
![Screenshot 2025-02-21 at 5 25
41 PM](https://github.com/user-attachments/assets/0fb269e2-db40-488b-b11d-8bdfbe2a5245)
Moderator's view after:
![Screenshot 2025-02-21 at 5 26
59 PM](https://github.com/user-attachments/assets/efb848b0-1d7f-4ec9-8238-d8ee4eddbbe1)

Moderator's view before:
![Screenshot 2025-02-21 at 5 23
52 PM](https://github.com/user-attachments/assets/226e6d63-df3e-45d0-833f-de52593a086e)
Moderator's view after:
![Screenshot 2025-02-21 at 5 23
15 PM](https://github.com/user-attachments/assets/af313af2-2329-46d1-827d-290243c320e5)

---------

Co-authored-by: Bennett Dungan <bennettdungan@gmail.com>
2025-08-05 10:09:02 -05:00
..
db/migrate FEATURE: Themeable site settings (#32233) 2025-07-16 11:00:21 +10:00
fabricators FEATURE: Enable rich editor for all users (#33699) 2025-07-28 10:08:50 +10:00
fixtures FIX: correctly unescape title for amazon oneboxes (#33010) 2025-06-02 17:50:13 +05:30
generator DEV: Silence the output of migration specs (#26365) 2024-03-26 11:32:44 +01:00
helpers FEATURE: Add dark color scheme setting for themes (#33967) 2025-08-04 12:33:41 +08:00
import_export DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
initializers DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
integration DEV: Only write session cookie when contents is changed (#33828) 2025-07-25 11:07:07 +01:00
integrity FIX: cross origin opener policy should apply to public error responses (#31559) 2025-03-03 17:04:24 +08:00
jobs FEATURE: Add support for aws MediaConvert (#33092) 2025-07-23 11:58:33 -06:00
lib FEATURE: add option to hide IP addresses from moderators (#33682) 2025-08-05 10:09:02 -05:00
mailers DEV: Remove ability to use users' names in group mention notifications and mentions shown in emails and added :user_notification_email_options plugin modifier to allow plugins reintroduce this or other modifications to emails (#33449) 2025-07-14 15:20:08 -05:00
models FEATURE: Localize topic titles in notifications and bookmarks (#34059) 2025-08-05 12:12:22 +08:00
multisite FEATURE: Themeable site settings (#32233) 2025-07-16 11:00:21 +10:00
queries/reports DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
requests FEATURE: add option to hide IP addresses from moderators (#33682) 2025-08-05 10:09:02 -05:00
script/import_scripts DEV: Catch missing translations during test runs (#26258) 2024-05-24 22:15:53 +08:00
serializers FEATURE: add option to hide IP addresses from moderators (#33682) 2025-08-05 10:09:02 -05:00
services DEV: Fix flakey spec with media convert (#33906) 2025-07-28 12:27:43 -06:00
support DEV: updates playwright to 1.54 (#33715) 2025-07-24 10:07:31 +02:00
system DEV: Convert FilterTips to use DMenu and refactor components (#33999) 2025-08-05 12:10:40 +10:00
tasks DEV: Only load specific plugin bundles during qunit test (#33678) 2025-07-21 21:00:48 +01:00
views FIX: correctly displaying the failure error message 2025-06-25 10:25:41 +08:00
rails_helper.rb DEV: Clear serializers cache between tests (#34008) 2025-07-31 17:21:22 +03:00
regenerate_swagger_docs DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
swagger_helper.rb DEV: Bump rswag-specs from 2.11.0 to 2.13.0 (#24654) 2023-12-07 08:16:47 +08:00