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

Commit

Permalink
Get rid of the mark_as_used parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Gliech <quenting@element.io>
  • Loading branch information
sandhose committed Aug 17, 2022
1 parent 6e41a06 commit 1670733
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async def _wrapped_get_user_by_req(
if not requester:
# If not, it should be from a regular user
requester = await self.get_user_by_access_token(
access_token, allow_expired=allow_expired, mark_as_used=True
access_token, allow_expired=allow_expired
)

# Deny the request if the user account has expired.
Expand Down Expand Up @@ -350,16 +350,13 @@ async def get_user_by_access_token(
self,
token: str,
allow_expired: bool = False,
mark_as_used: bool = False,
) -> Requester:
"""Validate access token and get user_id from it
Args:
token: The access token to get the user by
allow_expired: If False, raises an InvalidClientTokenError
if the token is expired
mark_as_used: Mark the token as used, if it was used to
authenticate a regular C-S API request
Raises:
InvalidClientTokenError if a user by that token exists, but the token is
Expand All @@ -386,8 +383,7 @@ async def get_user_by_access_token(

# Mark the token as used. This is used to invalidate old refresh
# tokens after some time.
if mark_as_used and not user_info.token_used:
await self.store.mark_access_token_as_used(user_info.token_id)
await self.store.mark_access_token_as_used(user_info.token_id)

requester = create_requester(
user_id=user_info.user_id,
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def check_username(
400, "User ID already taken.", errcode=Codes.USER_IN_USE
)
if guest_access_token:
user_data = await self.auth.get_user_by_access_token(guest_access_token)
user_data = await self.store.get_user_by_access_token(guest_access_token)
if not user_data.is_guest or user_data.user.localpart != localpart:
raise AuthError(
403,
Expand Down

0 comments on commit 1670733

Please sign in to comment.