discourse/app/assets/javascripts
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
..
admin FEATURE: add option to hide IP addresses from moderators (#33682) 2025-08-05 10:09:02 -05:00
custom-proxy Build(deps-dev): Bump glob from 10.4.5 to 11.0.3 (#33191) 2025-07-25 19:13:32 +02:00
deprecation-silencer
dialog-holder Build(deps-dev): Bump webpack from 5.100.2 to 5.101.0 (#33899) 2025-07-28 17:53:05 +02:00
discourse UX: subcategory image tweaks (#34083) 2025-08-05 08:47:14 -05:00
discourse-i18n DEV: Add an InterpolatedTranslation component. (#33082) 2025-06-17 07:52:06 +10:00
discourse-markdown-it FEATURE: add unicode username support for composer rich text (#33734) 2025-07-29 10:06:48 +04:00
discourse-plugins Build(deps-dev): Bump ember-cli from 6.5.0 to 6.6.0 (#33949) 2025-07-30 02:37:28 +02:00
discourse-widget-hbs Build(deps-dev): Bump ember-cli from 6.5.0 to 6.6.0 (#33949) 2025-07-30 02:37:28 +02:00
docs
ember-addons
ember-cli-progress-ci
float-kit Build(deps): Bump @floating-ui/dom from 1.7.2 to 1.7.3 (#33989) 2025-07-31 08:46:23 +02:00
pretty-text Build(deps-dev): Bump ember-cli from 6.5.0 to 6.6.0 (#33949) 2025-07-30 02:37:28 +02:00
select-kit UX: direct to single tag page from tag intersection when one tag remains (#34038) 2025-08-04 09:42:25 -04:00
theme-transpiler Build(deps): Bump memfs from 4.26.0 to 4.36.0 (#34049) 2025-08-04 01:44:39 +02:00
truth-helpers DEV: Correct truth-helper exports (#31528) 2025-02-26 17:50:29 +00:00
.npmrc
polyfills.js