diff --git a/web/src/settings_components.ts b/web/src/settings_components.ts index bfdce0d5ea..bb41cd48c6 100644 --- a/web/src/settings_components.ts +++ b/web/src/settings_components.ts @@ -901,6 +901,32 @@ export function check_property_changed( return current_val !== proposed_val; } +function get_request_data_for_org_join_restrictions(selected_val: string): { + disallow_disposable_email_addresses: boolean; + emails_restricted_to_domains: boolean; +} { + switch (selected_val) { + case "only_selected_domain": { + return { + emails_restricted_to_domains: true, + disallow_disposable_email_addresses: false, + }; + } + case "no_disposable_email": { + return { + emails_restricted_to_domains: false, + disallow_disposable_email_addresses: true, + }; + } + default: { + return { + disallow_disposable_email_addresses: false, + emails_restricted_to_domains: false, + }; + } + } +} + export function populate_data_for_request( $subsection_elem: JQuery, for_realm_default_settings: boolean, @@ -966,6 +992,14 @@ export function populate_data_for_request( }); continue; } + + if (property_name === "org_join_restrictions") { + data = { + ...data, + ...get_request_data_for_org_join_restrictions(input_value.toString()), + }; + continue; + } data[property_name] = input_value; } } diff --git a/web/src/settings_org.js b/web/src/settings_org.js index cc801bc269..63a3cbea29 100644 --- a/web/src/settings_org.js +++ b/web/src/settings_org.js @@ -880,24 +880,6 @@ export function register_save_discard_widget_handlers( let data = {}; switch (subsection) { - case "join_settings": { - const org_join_restrictions = $("#id_realm_org_join_restrictions").val(); - switch (org_join_restrictions) { - case "only_selected_domain": - data.emails_restricted_to_domains = true; - data.disallow_disposable_email_addresses = false; - break; - case "no_disposable_email": - data.emails_restricted_to_domains = false; - data.disallow_disposable_email_addresses = true; - break; - case "no_restriction": - data.disallow_disposable_email_addresses = false; - data.emails_restricted_to_domains = false; - break; - } - break; - } case "auth_settings": data = {}; data.authentication_methods = JSON.stringify( diff --git a/web/templates/settings/organization_permissions_admin.hbs b/web/templates/settings/organization_permissions_admin.hbs index 5e38eb1d9b..5c6ae77aa6 100644 --- a/web/templates/settings/organization_permissions_admin.hbs +++ b/web/templates/settings/organization_permissions_admin.hbs @@ -30,7 +30,7 @@