Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix some formatting problems
Browse files Browse the repository at this point in the history
Signed-off-by: Callum Brown <callum@calcuode.com>
  • Loading branch information
govynnus committed Jun 17, 2021
1 parent 7883191 commit 1debc22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,10 @@ async def registration_token_is_valid(self, token: str) -> bool:
return False

# Check if the token has been used up
if res["uses_allowed"] and res["pending"] + res["completed"] >= res["uses_allowed"]:
if (
res["uses_allowed"]
and res["pending"] + res["completed"] >= res["uses_allowed"]
):
return False

# Otherwise, the token is valid
Expand Down Expand Up @@ -1815,7 +1818,10 @@ def _set_registration_token_pending_txn(txn):
)

async def use_registration_token(self, token: str) -> None:
"""Increment the completed registrations counter for a token.
"""Complete a use of the given registration token.
The `pending` counter will be decremented, and the `completed`
counter will be incremented.
Args:
token: The registration token to be 'used'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
CREATE TABLE IF NOT EXISTS registration_tokens(
token TEXT NOT NULL, -- The token that can be used for authentication.
uses_allowed INT, -- The total number of times this token can be used. NULL if no limit.
pending INT NOT NULL, -- The number of in progress registrations using this token.
completed INT NOT NULL, -- The number of times this token has been used to complete a registration.
pending INT NOT NULL, -- The number of in progress registrations using this token.
completed INT NOT NULL, -- The number of times this token has been used to complete a registration.
expiry_time BIGINT, -- The latest time this token will be valid (epoch time in milliseconds). NULL if token doesn't expire.
UNIQUE (token)
);
2 changes: 1 addition & 1 deletion tests/rest/client/v2_alpha/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def test_POST_registration_token_limit_uses(self):
"session": session1,
}
self.make_request(b"POST", self.url, json.dumps(params1))
# Repeat request to make sure pending isn't set increased again
# Repeat request to make sure pending isn't increased again
self.make_request(b"POST", self.url, json.dumps(params1))
pending = self.get_success(
store.db_pool.simple_select_one_onecol(
Expand Down

0 comments on commit 1debc22

Please sign in to comment.