mirror of https://github.com/zulip/zulip.git
api: Fix encoding of strings in realm domain endpoint.
* Remove unnecessary json_validator for string parameters. * Update frontend to pass right parameters. Fixes part of #18035.
This commit is contained in:
parent
b2111f5753
commit
d4219da254
|
@ -1024,7 +1024,7 @@ export function build_page() {
|
|||
const domain = widget.find(".new-realm-domain").val();
|
||||
const allow_subdomains = widget.find(".new-realm-domain-allow-subdomains").prop("checked");
|
||||
const data = {
|
||||
domain: JSON.stringify(domain),
|
||||
domain,
|
||||
allow_subdomains: JSON.stringify(allow_subdomains),
|
||||
};
|
||||
|
||||
|
|
|
@ -48,13 +48,13 @@ class RealmDomainTest(ZulipTestCase):
|
|||
def test_create_realm_domain(self) -> None:
|
||||
self.login("iago")
|
||||
data = {
|
||||
"domain": orjson.dumps("").decode(),
|
||||
"domain": "",
|
||||
"allow_subdomains": orjson.dumps(True).decode(),
|
||||
}
|
||||
result = self.client_post("/json/realm/domains", info=data)
|
||||
self.assert_json_error(result, "Invalid domain: Domain can't be empty.")
|
||||
|
||||
data["domain"] = orjson.dumps("acme.com").decode()
|
||||
data["domain"] = "acme.com"
|
||||
result = self.client_post("/json/realm/domains", info=data)
|
||||
self.assert_json_success(result)
|
||||
realm = get_realm("zulip")
|
||||
|
|
|
@ -7,7 +7,7 @@ from zerver.lib.actions import do_add_realm_domain, do_change_realm_domain, do_r
|
|||
from zerver.lib.domains import validate_domain
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_bool, check_string
|
||||
from zerver.lib.validator import check_bool
|
||||
from zerver.models import RealmDomain, UserProfile, get_realm_domains
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ def list_realm_domains(request: HttpRequest, user_profile: UserProfile) -> HttpR
|
|||
def create_realm_domain(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
domain: str = REQ(json_validator=check_string),
|
||||
domain: str = REQ(),
|
||||
allow_subdomains: bool = REQ(json_validator=check_bool),
|
||||
) -> HttpResponse:
|
||||
domain = domain.strip().lower()
|
||||
|
|
Loading…
Reference in New Issue