login: Enable non-email username to login.

This commit is contained in:
Supermanu
2017-09-10 20:42:07 +02:00
committed by Tim Abbott
parent 5f41f3c3cb
commit ac79bbfe08
2 changed files with 15 additions and 2 deletions

View File

@@ -73,10 +73,19 @@ common.autofocus('#id_username');
<!-- .no-validation is for removing the red star in CSS --> <!-- .no-validation is for removing the red star in CSS -->
<div class="input-box no-validation"> <div class="input-box no-validation">
<input id="id_username" type="email" name="username" class="email required" <input id="id_username" type="{% if not require_email_format_usernames %}text{% else %}email{% endif %}"
name="username" class="{% if require_email_format_usernames %}email {% endif %}required"
{% if email %} value="{{ email }}" {% else %} value="" {% endif %} {% if email %} value="{{ email }}" {% else %} value="" {% endif %}
maxlength="72" required /> maxlength="72" required />
<label for="id_username">{{ _('Email') }}</label> <label for="id_username">
{% if not require_email_format_usernames and email_auth_enabled %}
{{ _('Email or username') }}
{% elif not require_email_format_usernames %}
{{ _('Username') }}
{% else %}
{{ _('Email') }}
{% endif %}
</label>
</div> </div>
<div class="input-box no-validation"> <div class="input-box no-validation">

View File

@@ -11,6 +11,8 @@ from zproject.backends import (
github_auth_enabled, github_auth_enabled,
google_auth_enabled, google_auth_enabled,
password_auth_enabled, password_auth_enabled,
email_auth_enabled,
require_email_format_usernames,
auth_enabled_helper, auth_enabled_helper,
AUTH_BACKEND_NAME_MAP AUTH_BACKEND_NAME_MAP
) )
@@ -127,6 +129,8 @@ def zulip_default_context(request):
'dev_auth_enabled': dev_auth_enabled(realm), 'dev_auth_enabled': dev_auth_enabled(realm),
'google_auth_enabled': google_auth_enabled(realm), 'google_auth_enabled': google_auth_enabled(realm),
'github_auth_enabled': github_auth_enabled(realm), 'github_auth_enabled': github_auth_enabled(realm),
'email_auth_enabled': email_auth_enabled(realm),
'require_email_format_usernames': require_email_format_usernames(realm),
'any_oauth_backend_enabled': any_oauth_backend_enabled(realm), 'any_oauth_backend_enabled': any_oauth_backend_enabled(realm),
'no_auth_enabled': not auth_enabled_helper(list(AUTH_BACKEND_NAME_MAP.keys()), realm), 'no_auth_enabled': not auth_enabled_helper(list(AUTH_BACKEND_NAME_MAP.keys()), realm),
'development_environment': settings.DEVELOPMENT, 'development_environment': settings.DEVELOPMENT,