summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2021-02-01 17:30:42 +0000
committerGitHub <noreply@github.com>2021-02-01 17:30:42 +0000
commit85c56b5a679add887ec9716f176949561dca581b (patch)
treeec00c2d951fec3f32a29fd8e586196a9fe4a666a /synapse/rest
parentReplace username picker with a template (#9275) (diff)
downloadsynapse-85c56b5a679add887ec9716f176949561dca581b.tar.xz
Make importing display name and email optional (#9277)
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/synapse/client/pick_username.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/rest/synapse/client/pick_username.py b/synapse/rest/synapse/client/pick_username.py
index 27540d3bbe..96077cfcd1 100644
--- a/synapse/rest/synapse/client/pick_username.py
+++ b/synapse/rest/synapse/client/pick_username.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 import logging
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, List
 
 from twisted.web.http import Request
 from twisted.web.resource import Resource
@@ -26,7 +26,7 @@ from synapse.http.server import (
     DirectServeJsonResource,
     respond_with_html,
 )
-from synapse.http.servlet import parse_string
+from synapse.http.servlet import parse_boolean, parse_string
 from synapse.http.site import SynapseRequest
 from synapse.util.templates import build_jinja_env
 
@@ -113,11 +113,19 @@ class AccountDetailsResource(DirectServeHtmlResource):
 
         try:
             localpart = parse_string(request, "username", required=True)
+            use_display_name = parse_boolean(request, "use_display_name", default=False)
+
+            try:
+                emails_to_use = [
+                    val.decode("utf-8") for val in request.args.get(b"use_email", [])
+                ]  # type: List[str]
+            except ValueError:
+                raise SynapseError(400, "Query parameter use_email must be utf-8")
         except SynapseError as e:
             logger.warning("[session %s] bad param: %s", session_id, e)
             self._sso_handler.render_error(request, "bad_param", e.msg, code=e.code)
             return
 
         await self._sso_handler.handle_submit_username_request(
-            request, localpart, session_id
+            request, session_id, localpart, use_display_name, emails_to_use
         )