Remove old is_super_user helper functions.

(imported from commit 85655ea9369f5dc309f6f687bac578924571c9ee)
This commit is contained in:
Tim Abbott
2015-09-20 10:50:06 -07:00
parent 858d0a984b
commit b68d116e3a
4 changed files with 7 additions and 13 deletions

View File

@@ -12,7 +12,7 @@ from zerver.models import Realm, RealmEmoji, Stream, UserProfile, UserActivity,
get_user_profile_by_id, PreregistrationUser, get_display_recipient, \ get_user_profile_by_id, PreregistrationUser, get_display_recipient, \
to_dict_cache_key, get_realm, stringify_message_dict, bulk_get_recipients, \ to_dict_cache_key, get_realm, stringify_message_dict, bulk_get_recipients, \
resolve_email_to_domain, email_to_username, display_recipient_cache_key, \ resolve_email_to_domain, email_to_username, display_recipient_cache_key, \
get_stream_cache_key, to_dict_cache_key_id, is_super_user, \ get_stream_cache_key, to_dict_cache_key_id, \
UserActivityInterval, get_active_user_dicts_in_realm, get_active_streams, \ UserActivityInterval, get_active_user_dicts_in_realm, get_active_streams, \
realm_filters_for_domain, RealmFilter, receives_offline_notifications, \ realm_filters_for_domain, RealmFilter, receives_offline_notifications, \
ScheduledJob, realm_filters_for_domain, RealmFilter, get_active_bot_dicts_in_realm ScheduledJob, realm_filters_for_domain, RealmFilter, get_active_bot_dicts_in_realm
@@ -762,8 +762,8 @@ def check_message(sender, client, message_type_name, message_to,
elif subscribed_to_stream(sender, stream): elif subscribed_to_stream(sender, stream):
# Or it is private, but your are subscribed # Or it is private, but your are subscribed
pass pass
elif is_super_user(sender) or (forwarder_user_profile is not None and elif sender.is_api_super_user() or (forwarder_user_profile is not None and
is_super_user(forwarder_user_profile)): forwarder_user_profile.is_api_super_user()):
# Or this request is being done on behalf of a super user # Or this request is being done on behalf of a super user
pass pass
elif sender.is_bot and subscribed_to_stream(sender.bot_owner, stream): elif sender.is_bot and subscribed_to_stream(sender.bot_owner, stream):
@@ -2820,7 +2820,7 @@ def get_occupied_streams(realm):
def do_get_streams(user_profile, include_public=True, include_subscribed=True, def do_get_streams(user_profile, include_public=True, include_subscribed=True,
include_all_active=False): include_all_active=False):
if include_all_active and not is_super_user(user_profile): if include_all_active and not user_profile.is_api_super_user():
raise JsonableError("User not authorized for this query") raise JsonableError("User not authorized for this query")
# Listing public streams are disabled for the mit.edu realm. # Listing public streams are disabled for the mit.edu realm.

View File

@@ -34,12 +34,6 @@ bugdown = None
MAX_SUBJECT_LENGTH = 60 MAX_SUBJECT_LENGTH = 60
MAX_MESSAGE_LENGTH = 10000 MAX_MESSAGE_LENGTH = 10000
def is_super_user(user_profile):
return user_profile.is_api_super_user()
def is_super_user_api(request):
return request.user.is_authenticated() and is_super_user(request.user)
# Doing 1000 memcached requests to get_display_recipient is quite slow, # Doing 1000 memcached requests to get_display_recipient is quite slow,
# so add a local cache as well as the memcached cache. # so add a local cache as well as the memcached cache.
per_request_display_recipient_cache = {} per_request_display_recipient_cache = {}

View File

@@ -23,7 +23,7 @@ from zerver.models import Message, UserProfile, Stream, Subscription, Huddle, \
RealmFilter, bulk_get_recipients, \ RealmFilter, bulk_get_recipients, \
PreregistrationUser, get_client, MitUser, UserActivity, PushDeviceToken, \ PreregistrationUser, get_client, MitUser, UserActivity, PushDeviceToken, \
get_stream, bulk_get_streams, UserPresence, \ get_stream, bulk_get_streams, UserPresence, \
get_recipient, valid_stream_name, is_super_user_api, \ get_recipient, valid_stream_name, \
split_email_to_domain, resolve_email_to_domain, email_to_username, get_realm, \ split_email_to_domain, resolve_email_to_domain, email_to_username, get_realm, \
completely_open, get_unique_open_realm, get_active_user_dicts_in_realm, remote_user_to_email completely_open, get_unique_open_realm, get_active_user_dicts_in_realm, remote_user_to_email
from zerver.lib.actions import bulk_remove_subscriptions, do_change_password, \ from zerver.lib.actions import bulk_remove_subscriptions, do_change_password, \

View File

@@ -25,7 +25,7 @@ from zerver.models import Message, UserProfile, Stream, Subscription, \
Recipient, UserMessage, bulk_get_recipients, get_recipient, \ Recipient, UserMessage, bulk_get_recipients, get_recipient, \
get_user_profile_by_email, get_stream, valid_stream_name, \ get_user_profile_by_email, get_stream, valid_stream_name, \
parse_usermessage_flags, to_dict_cache_key_id, extract_message_dict, \ parse_usermessage_flags, to_dict_cache_key_id, extract_message_dict, \
stringify_message_dict, is_super_user, is_super_user_api, \ stringify_message_dict, \
resolve_email_to_domain, get_realm, get_active_streams, \ resolve_email_to_domain, get_realm, get_active_streams, \
bulk_get_streams bulk_get_streams
@@ -718,7 +718,7 @@ def send_message_backend(request, user_profile,
local_id = REQ(default=None), local_id = REQ(default=None),
queue_id = REQ(default=None)): queue_id = REQ(default=None)):
client = request.client client = request.client
is_super_user = is_super_user_api(request) is_super_user = request.user.is_api_super_user()
if forged and not is_super_user: if forged and not is_super_user:
return json_error("User not authorized for this query") return json_error("User not authorized for this query")