Skip to content

Commit

Permalink
Hide private IPs from account activity for non-admins.
Browse files Browse the repository at this point in the history
mobile-web keeps cropping up with a bug that puts private IPs into
the account history for users. Best not to worry them with such
things and hide it from their activity page.
  • Loading branch information
kjoconnor committed Aug 3, 2015
1 parent e49c0a0 commit c9c4342
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions r2/r2/lib/pages/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from collections import Counter, OrderedDict

from r2.config import feature
from r2.lib.contrib.ipaddress import ip_address
from r2.lib.db.operators import asc
from r2.lib.wrapped import Wrapped, Templated, CachedTemplate
from r2.models import (
Expand Down Expand Up @@ -4876,6 +4877,13 @@ class UserIPHistory(Templated):
def __init__(self):
self.my_apps = OAuth2Client._by_user_grouped(c.user)
self.ips = ips_by_account_id(c.user._id)

if not c.user_is_admin:
self.ips = [
ip
for ip in self.ips
if not ip_address(ip[0]).is_private
]
super(UserIPHistory, self).__init__()

class ApiHelp(Templated):
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/lib/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
gold_summary_gilding_page_link = _("You're about to give *%(recipient)s* a month of [reddit gold](/gold/about) for this submission:"),
gold_summary_gilding_page_footer = _("You'll pay a total of %(price)s for this."),
unvotable_message = _("sorry, this has been archived and can no longer be voted on"),
account_activity_blurb = _("This page shows a history of recent activity on your account. If you notice unusual activity, you should change your password immediately. Location information is guessed from your computer's IP address and may be wildly wrong, especially for visits from mobile devices. Note: due to a bug, private-use addresses (starting with 10.) sometimes show up erroneously in this list after regular use of the site."),
account_activity_blurb = _("This page shows a history of recent activity on your account. If you notice unusual activity, you should change your password immediately. Location information is guessed from your computer's IP address and may be wildly wrong, especially for visits from mobile devices."),
your_current_ip_is = _("You are currently accessing reddit from this IP address: %(address)s."),
account_activity_apps_blurb = _("""
These apps are authorized to access your account. Signing out of all sessions
Expand Down

0 comments on commit c9c4342

Please sign in to comment.