mirror of
https://github.com/zulip/zulip.git
synced 2026-07-18 21:04:19 +08:00
Prevent MIT users from sending invites and hide the button.
(imported from commit 0388c4a2253514e0aba15605bd75a87543479312)
This commit is contained in:
parent
57d8b8d30c
commit
75004c65f2
@ -138,12 +138,14 @@ var people_list = [
|
||||
<span class="hidden-phone"> Feedback</span>
|
||||
</a>
|
||||
</li>
|
||||
{% if show_invites %}
|
||||
<li title="Invite users to Humbug">
|
||||
<a href="#invite-user" role="button" data-toggle="modal">
|
||||
<i class="icon-gift"></i>
|
||||
<span class="hidden-phone"> Invite users to Humbug</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<hr class="sidebar"/>
|
||||
<li title="Log out">
|
||||
<a href="/accounts/logout">
|
||||
|
||||
@ -22,7 +22,7 @@ from zephyr.lib.actions import do_add_subscription, do_remove_subscription, \
|
||||
log_subscription_property_change, internal_send_message, \
|
||||
create_stream_if_needed
|
||||
from zephyr.forms import RegistrationForm, HomepageForm, ToSForm, is_unique, \
|
||||
is_active
|
||||
is_active, isnt_mit
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from zephyr.decorator import require_post, \
|
||||
@ -167,6 +167,12 @@ def accounts_accept_terms(request):
|
||||
@has_request_variables
|
||||
def json_invite_users(request, user_profile, invitee_emails=POST):
|
||||
# Validation
|
||||
if settings.ALLOW_REGISTER == False:
|
||||
try:
|
||||
isnt_mit(user_profile.user.email)
|
||||
except ValidationError:
|
||||
return json_error("Invitations are not enabled for MIT at this time.")
|
||||
|
||||
if not invitee_emails:
|
||||
return json_error("You must specify at least one email address.")
|
||||
|
||||
@ -199,6 +205,15 @@ def json_invite_users(request, user_profile, invitee_emails=POST):
|
||||
errors.append((email, "Outside your domain."))
|
||||
continue
|
||||
|
||||
# Redundant check in case earlier validation preventing MIT users from
|
||||
# inviting people fails.
|
||||
if settings.ALLOW_REGISTER == False:
|
||||
try:
|
||||
isnt_mit(email)
|
||||
except ValidationError:
|
||||
errors.append((email, "Invitations are not enabled for MIT at this time."))
|
||||
continue
|
||||
|
||||
try:
|
||||
is_unique(email)
|
||||
except ValidationError:
|
||||
@ -303,6 +318,12 @@ def home(request):
|
||||
|
||||
js_bool = lambda x: 'true' if x else 'false'
|
||||
|
||||
try:
|
||||
isnt_mit(user_profile.user.email)
|
||||
show_invites = True
|
||||
except ValidationError:
|
||||
show_invites = settings.ALLOW_REGISTER
|
||||
|
||||
return render_to_response('zephyr/index.html',
|
||||
{'user_profile': user_profile,
|
||||
'email_hash' : gravatar_hash(user_profile.user.email),
|
||||
@ -315,7 +336,8 @@ def home(request):
|
||||
js_bool(desktop_notifications_enabled),
|
||||
'show_debug':
|
||||
settings.DEBUG and ('show_debug' in request.GET),
|
||||
'show_activity': can_view_activity(request) },
|
||||
'show_activity': can_view_activity(request),
|
||||
'show_invites': show_invites },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
@authenticated_api_view
|
||||
|
||||
Loading…
Reference in New Issue
Block a user