mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
home.py: move password_auth_enabled as realm_password_auth_enabled.
Part of #3853.
This commit is contained in:
@@ -40,7 +40,7 @@ exports.set_up = function () {
|
||||
e.preventDefault();
|
||||
$('#pw_change_link').hide();
|
||||
$('#pw_change_controls').show();
|
||||
if (page_params.password_auth_enabled !== false) {
|
||||
if (page_params.realm_password_auth_enabled !== false) {
|
||||
// zxcvbn.js is pretty big, and is only needed on password
|
||||
// change, so load it asynchronously.
|
||||
var zxcvbn_path = '/static/min/zxcvbn.js';
|
||||
@@ -63,7 +63,7 @@ exports.set_up = function () {
|
||||
$("form.your-account-settings").ajaxForm({
|
||||
dataType: 'json', // This seems to be ignored. We still get back an xhr.
|
||||
beforeSubmit: function () {
|
||||
if (page_params.password_auth_enabled !== false) {
|
||||
if (page_params.realm_password_auth_enabled !== false) {
|
||||
// FIXME: Check that the two password fields match
|
||||
// FIXME: Use the same jQuery validation plugin as the signup form?
|
||||
var field = $('#new_password');
|
||||
|
||||
@@ -63,7 +63,7 @@ exports.set_up = function () {
|
||||
$("#api_key_button_box").show();
|
||||
|
||||
$('#api_key_button').click(function () {
|
||||
if (page_params.password_auth_enabled !== false) {
|
||||
if (page_params.realm_password_auth_enabled !== false) {
|
||||
$("#get_api_key_box").show();
|
||||
} else {
|
||||
// Skip the password prompt step
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</div>
|
||||
|
||||
<!-- password start -->
|
||||
{{#if page_params.password_auth_enabled}}
|
||||
{{#if page_params.realm_password_auth_enabled}}
|
||||
<div class="input-group" id="pw_change_link">
|
||||
<label for="change_password_button" class="inline-block title">{{t "Password" }}</label>
|
||||
<button class="change_password_button button white rounded inline-block input-size" data-dismiss="modal" aria-hidden="true">{{t "Change password" }}</button>
|
||||
|
||||
@@ -33,6 +33,7 @@ from zerver.models import Client, Message, Realm, UserPresence, UserProfile, \
|
||||
get_user_profile_by_email, get_user_profile_by_id, \
|
||||
get_active_user_dicts_in_realm, realm_filters_for_realm, \
|
||||
get_owned_bot_dicts, custom_profile_fields_for_realm, get_realm_domains
|
||||
from zproject.backends import password_auth_enabled
|
||||
from version import ZULIP_VERSION
|
||||
|
||||
|
||||
@@ -115,6 +116,7 @@ def fetch_initial_state_data(user_profile, event_types, queue_id,
|
||||
state['realm_mandatory_topics'] = user_profile.realm.mandatory_topics
|
||||
state['realm_show_digest_email'] = user_profile.realm.show_digest_email
|
||||
state['realm_is_zephyr_mirror_realm'] = user_profile.realm.is_zephyr_mirror_realm
|
||||
state['realm_password_auth_enabled'] = password_auth_enabled(user_profile.realm)
|
||||
|
||||
if want('realm_domains'):
|
||||
state['realm_domains'] = get_realm_domains(user_profile.realm)
|
||||
@@ -292,6 +294,11 @@ def apply_event(state, event, user_profile, include_subscribers):
|
||||
elif event['op'] == "update_dict":
|
||||
for key, value in event['data'].items():
|
||||
state['realm_' + key] = value
|
||||
# It's a bit messy, but this is where we need to
|
||||
# update the state for whether password authentication
|
||||
# is enabled on this server.
|
||||
if key == 'authentication_methods':
|
||||
state['realm_password_auth_enabled'] = (value['Email'] or value['LDAP'])
|
||||
elif event['type'] == "subscription":
|
||||
if not include_subscribers and event['op'] in ['peer_add', 'peer_remove']:
|
||||
return
|
||||
|
||||
@@ -90,7 +90,6 @@ class HomeTest(ZulipTestCase):
|
||||
"needs_tutorial",
|
||||
"neversubbed_info",
|
||||
"notifications_stream",
|
||||
"password_auth_enabled",
|
||||
"people_list",
|
||||
"pm_content_in_desktop_notifications",
|
||||
"poll_timeout",
|
||||
@@ -119,6 +118,7 @@ class HomeTest(ZulipTestCase):
|
||||
"realm_message_retention_days",
|
||||
"realm_name",
|
||||
"realm_name_changes_disabled",
|
||||
"realm_password_auth_enabled",
|
||||
"realm_presence_disabled",
|
||||
"realm_restricted_to_domain",
|
||||
"realm_show_digest_email",
|
||||
|
||||
@@ -26,7 +26,6 @@ from zerver.lib.i18n import get_language_list, get_language_name, \
|
||||
from zerver.lib.push_notifications import num_push_devices_for_user
|
||||
from zerver.lib.streams import access_stream_by_name
|
||||
from zerver.lib.utils import statsd, get_subdomain
|
||||
from zproject.backends import password_auth_enabled
|
||||
|
||||
import calendar
|
||||
import datetime
|
||||
@@ -209,10 +208,6 @@ def home_real(request):
|
||||
server_inline_image_preview = settings.INLINE_IMAGE_PREVIEW,
|
||||
server_inline_url_embed_preview = settings.INLINE_URL_EMBED_PREVIEW,
|
||||
|
||||
# realm data.
|
||||
# TODO: Move all of these data to register_ret and pull from there
|
||||
password_auth_enabled = password_auth_enabled(user_profile.realm),
|
||||
|
||||
# user_profile data.
|
||||
# TODO: Move all of these data to register_ret and pull from there
|
||||
fullname = user_profile.full_name,
|
||||
@@ -308,6 +303,7 @@ def home_real(request):
|
||||
'realm_name',
|
||||
'realm_description',
|
||||
'realm_name_changes_disabled',
|
||||
'realm_password_auth_enabled',
|
||||
'realm_presence_disabled',
|
||||
'realm_restricted_to_domain',
|
||||
'realm_show_digest_email',
|
||||
|
||||
Reference in New Issue
Block a user