mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Merge pull request #2213 from matrix-org/luke/username-availability-qp
Modify register/available to be GET with query param
This commit is contained in:
commit
c1935f0a41
@ -54,6 +54,13 @@ class RegistrationHandler(BaseHandler):
|
|||||||
Codes.INVALID_USERNAME
|
Codes.INVALID_USERNAME
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not localpart:
|
||||||
|
raise SynapseError(
|
||||||
|
400,
|
||||||
|
"User ID cannot be empty",
|
||||||
|
Codes.INVALID_USERNAME
|
||||||
|
)
|
||||||
|
|
||||||
if localpart[0] == '_':
|
if localpart[0] == '_':
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400,
|
400,
|
||||||
|
@ -21,7 +21,7 @@ from synapse.api.auth import get_access_token_from_request, has_access_token
|
|||||||
from synapse.api.constants import LoginType
|
from synapse.api.constants import LoginType
|
||||||
from synapse.api.errors import SynapseError, Codes, UnrecognizedRequestError
|
from synapse.api.errors import SynapseError, Codes, UnrecognizedRequestError
|
||||||
from synapse.http.servlet import (
|
from synapse.http.servlet import (
|
||||||
RestServlet, parse_json_object_from_request, assert_params_in_request
|
RestServlet, parse_json_object_from_request, assert_params_in_request, parse_string
|
||||||
)
|
)
|
||||||
from synapse.util.msisdn import phone_number_to_msisdn
|
from synapse.util.msisdn import phone_number_to_msisdn
|
||||||
|
|
||||||
@ -142,15 +142,14 @@ class UsernameAvailabilityRestServlet(RestServlet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_POST(self, request):
|
def on_GET(self, request):
|
||||||
ip = self.hs.get_ip_from_request(request)
|
ip = self.hs.get_ip_from_request(request)
|
||||||
with self.ratelimiter.ratelimit(ip) as wait_deferred:
|
with self.ratelimiter.ratelimit(ip) as wait_deferred:
|
||||||
yield wait_deferred
|
yield wait_deferred
|
||||||
|
|
||||||
body = parse_json_object_from_request(request)
|
username = parse_string(request, "username", required=True)
|
||||||
assert_params_in_request(body, ['username'])
|
|
||||||
|
|
||||||
yield self.registration_handler.check_username(body['username'])
|
yield self.registration_handler.check_username(username)
|
||||||
|
|
||||||
defer.returnValue((200, {"available": True}))
|
defer.returnValue((200, {"available": True}))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user