Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
1fe3cc2c
Commit
1fe3cc2c
authored
5 years ago
by
Andrew Morgan
Browse files
Options
Downloads
Patches
Plain Diff
Address review comments
parent
d2f6a67c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/handlers/register.py
+12
-12
12 additions, 12 deletions
synapse/handlers/register.py
synapse/replication/http/register.py
+1
-1
1 addition, 1 deletion
synapse/replication/http/register.py
with
13 additions
and
13 deletions
synapse/handlers/register.py
+
12
−
12
View file @
1fe3cc2c
...
...
@@ -24,7 +24,6 @@ from synapse.api.errors import (
AuthError
,
Codes
,
ConsentNotGivenError
,
LimitExceededError
,
RegistrationError
,
SynapseError
,
)
...
...
@@ -218,8 +217,8 @@ class RegistrationHandler(BaseHandler):
else
:
# autogen a sequential user ID
user
=
None
while
not
user
:
# Fail after being unable to find a suitable ID a few times
for
x
in
range
(
10
)
:
localpart
=
yield
self
.
_generate_user_id
()
user
=
UserID
(
localpart
,
self
.
hs
.
hostname
)
user_id
=
user
.
to_string
()
...
...
@@ -234,10 +233,12 @@ class RegistrationHandler(BaseHandler):
create_profile_with_displayname
=
default_display_name
,
address
=
address
,
)
# Successfully registered
break
except
SynapseError
:
# if user id is taken, just generate another
user
=
None
user_id
=
None
pass
if
not
self
.
hs
.
config
.
user_consent_at_registration
:
yield
self
.
_auto_join_rooms
(
user_id
)
...
...
@@ -420,25 +421,24 @@ class RegistrationHandler(BaseHandler):
for a given IP address
Args:
address (str): the IP address used to perform the registration.
address (str|None): the IP address used to perform the registration. If this is
None, no ratelimiting will be performed.
Raises:
LimitExceededError: If the rate limit has been exceeded.
"""
if
not
address
:
return
time_now
=
self
.
clock
.
time
()
allowed
,
time_allowed
=
self
.
ratelimiter
.
can_do_action
(
self
.
ratelimiter
.
ratelimit
(
address
,
time_now_s
=
time_now
,
rate_hz
=
self
.
hs
.
config
.
rc_registration
.
per_second
,
burst_count
=
self
.
hs
.
config
.
rc_registration
.
burst_count
,
)
if
not
allowed
:
raise
LimitExceededError
(
retry_after_ms
=
int
(
1000
*
(
time_allowed
-
time_now
))
)
def
register_with_store
(
self
,
user_id
,
...
...
This diff is collapsed.
Click to expand it.
synapse/replication/http/register.py
+
1
−
1
View file @
1fe3cc2c
...
...
@@ -75,7 +75,7 @@ class ReplicationRegisterServlet(ReplicationEndpoint):
async
def
_handle_request
(
self
,
request
,
user_id
):
content
=
parse_json_object_from_request
(
request
)
await
self
.
registration_handler
.
check_registration_ratelimit
(
content
[
"
address
"
])
self
.
registration_handler
.
check_registration_ratelimit
(
content
[
"
address
"
])
await
self
.
registration_handler
.
register_with_store
(
user_id
=
user_id
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment