zilencer: Remove obsolete desktop_sso_dispatch.

This feature has been obsolete since when Zulip was released as open
source software, since it's purpose was to avoid putting a "server
url" prompt in the desktop app, and now that prompt is required
anyway.
This commit is contained in:
Tim Abbott 2017-03-05 23:17:34 -08:00
parent 70df1f5829
commit 9e8023843a
3 changed files with 7 additions and 48 deletions

View File

@ -30,9 +30,7 @@
{% if password_auth_enabled %}
<script type="text/javascript">
{% if email %}
{% if not desktop_sso_dispatch %}
autofocus('#id_password');
{% endif %}
{% else %}
autofocus('#id_username');
{% endif %}
@ -62,15 +60,11 @@ autofocus('#id_username');
{% else %}
{# Non-SSO users. #}
{% if form.errors or desktop_sso_unknown_email %}
{% if form.errors %}
<div class="alert alert-error">
{% if desktop_sso_unknown_email %}
{{ _('Zulip is not currently available for your domain.') }} <br />
{% else %}
{% for error in form.errors.values() %}
<div>{{ error | striptags }}</div>
{% endfor %}
{% endif %}
{% for error in form.errors.values() %}
<div>{{ error | striptags }}</div>
{% endfor %}
</div>
{% endif %}
@ -86,14 +80,9 @@ autofocus('#id_username');
</div>
{% endif %}
{% if password_auth_enabled or desktop_sso_dispatch %}
{% if password_auth_enabled %}
<form name="login_form" id="login_form" method="post" class="login-form"
{% if desktop_sso_dispatch %}
{# desktop_sso_dispatch is only set when this template is invoked by zilencer.views #}
action="{{ url('zilencer.views.account_deployment_dispatch') }}"
{% else %}
action="{{ url('django.contrib.auth.views.login') }}?next={{ next }}"
{% endif %}
>
{{ csrf_input }}
<div class="control-group">
@ -110,22 +99,19 @@ autofocus('#id_username');
</div>
</div>
{% if not desktop_sso_dispatch %}
<div class="control-group">
<label for="id_password" class="control-label">{{ _('Password') }}</label>
<div class="controls">
<input id="id_password" name="password" class="required" type="password" />
</div>
</div>
{% endif %}
<div class="control-group">
<div class="controls">
<input type="submit" class="btn btn-large btn-primary" value="Log in" />
{% if not desktop_sso_dispatch %}
<span class="login-forgot-password">
<a href="{{ url('django.contrib.auth.views.password_reset') }}">{{ _('Forgot password?') }}</a>
</span>
{% endif %}
</div>
</div>
</form>

View File

@ -4,14 +4,6 @@ import zilencer.views
import zerver.views.report
i18n_urlpatterns = [
# SSO dispatch page for desktop app with SSO
# Allows the user to enter their email address only,
# and then redirects the user to the proper deployment
# SSO-login page
url(r'^accounts/deployment_dispatch$',
zilencer.views.account_deployment_dispatch,
{'template_name': 'zerver/login.html'},
name='zilencer.views.account_deployment_dispatch',)
]
# Zilencer views following the REST API style
@ -27,4 +19,4 @@ v1_api_and_json_patterns = [
urlpatterns = [
url(r'^api/v1/', include(v1_api_and_json_patterns)),
url(r'^json/', include(v1_api_and_json_patterns)),
] + i18n_urlpatterns
]

View File

@ -3,8 +3,6 @@ from __future__ import absolute_import
from django.utils.translation import ugettext as _
from django.http import HttpResponse, HttpRequest
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.views import login as django_login_page
from django.http import HttpResponseRedirect
from zilencer.models import Deployment
@ -106,20 +104,3 @@ def lookup_endpoints_for_user(request, email=REQ()):
return json_response(realm_for_email(email).deployment.endpoints)
except AttributeError:
return json_error(_("Cannot determine endpoint for user."), status=404)
def account_deployment_dispatch(request, **kwargs):
# type: (HttpRequest, **Any) -> HttpResponse
sso_unknown_email = False
if request.method == 'POST':
email = request.POST['username']
realm = realm_for_email(email)
try:
return HttpResponseRedirect(realm.deployment.base_site_url)
except AttributeError:
# No deployment found for this user/email
sso_unknown_email = True
template_response = django_login_page(request, **kwargs)
template_response.context_data['desktop_sso_dispatch'] = True
template_response.context_data['desktop_sso_unknown_email'] = sso_unknown_email
return template_response