mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-11 12:31:58 +01:00
Rename get_access_token_for_user_id
method to create_access_token_for_user_id
(#11369)
This commit is contained in:
parent
60ecb6b4d4
commit
0d86f6334a
7 changed files with 16 additions and 15 deletions
1
changelog.d/11369.misc
Normal file
1
changelog.d/11369.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Rename `get_access_token_for_user_id` to `create_access_token_for_user_id` to better reflect what it does.
|
|
@ -793,7 +793,7 @@ class AuthHandler:
|
|||
) = await self.get_refresh_token_for_user_id(
|
||||
user_id=existing_token.user_id, device_id=existing_token.device_id
|
||||
)
|
||||
access_token = await self.get_access_token_for_user_id(
|
||||
access_token = await self.create_access_token_for_user_id(
|
||||
user_id=existing_token.user_id,
|
||||
device_id=existing_token.device_id,
|
||||
valid_until_ms=valid_until_ms,
|
||||
|
@ -855,7 +855,7 @@ class AuthHandler:
|
|||
)
|
||||
return refresh_token, refresh_token_id
|
||||
|
||||
async def get_access_token_for_user_id(
|
||||
async def create_access_token_for_user_id(
|
||||
self,
|
||||
user_id: str,
|
||||
device_id: Optional[str],
|
||||
|
|
|
@ -819,7 +819,7 @@ class RegistrationHandler:
|
|||
)
|
||||
valid_until_ms = self.clock.time_msec() + self.access_token_lifetime
|
||||
|
||||
access_token = await self._auth_handler.get_access_token_for_user_id(
|
||||
access_token = await self._auth_handler.create_access_token_for_user_id(
|
||||
user_id,
|
||||
device_id=registered_device_id,
|
||||
valid_until_ms=valid_until_ms,
|
||||
|
|
|
@ -898,7 +898,7 @@ class UserTokenRestServlet(RestServlet):
|
|||
if auth_user.to_string() == user_id:
|
||||
raise SynapseError(400, "Cannot use admin API to login as self")
|
||||
|
||||
token = await self.auth_handler.get_access_token_for_user_id(
|
||||
token = await self.auth_handler.create_access_token_for_user_id(
|
||||
user_id=auth_user.to_string(),
|
||||
device_id=None,
|
||||
valid_until_ms=valid_until_ms,
|
||||
|
|
|
@ -116,7 +116,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
|||
self.auth_blocking._limit_usage_by_mau = False
|
||||
# Ensure does not throw exception
|
||||
self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user1, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
@ -134,7 +134,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
|||
)
|
||||
|
||||
self.get_failure(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user1, device_id=None, valid_until_ms=None
|
||||
),
|
||||
ResourceLimitError,
|
||||
|
@ -162,7 +162,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# If not in monthly active cohort
|
||||
self.get_failure(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user1, device_id=None, valid_until_ms=None
|
||||
),
|
||||
ResourceLimitError,
|
||||
|
@ -179,7 +179,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
|||
return_value=make_awaitable(self.clock.time_msec())
|
||||
)
|
||||
self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user1, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
@ -197,7 +197,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
|||
)
|
||||
# Ensure does not raise exception
|
||||
self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user1, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1169,14 +1169,14 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
# regardless of whether password login or SSO is allowed
|
||||
self.admin_user = self.register_user("admin", "pass", admin=True)
|
||||
self.admin_user_tok = self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.admin_user, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
||||
self.other_user = self.register_user("user", "pass", displayname="User")
|
||||
self.other_user_token = self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.other_user, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
|
|
@ -71,7 +71,7 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
@override_config({"password_config": {"localdb_enabled": False}})
|
||||
def test_get_change_password_capabilities_localdb_disabled(self):
|
||||
access_token = self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
@ -85,7 +85,7 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
@override_config({"password_config": {"enabled": False}})
|
||||
def test_get_change_password_capabilities_password_disabled(self):
|
||||
access_token = self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
@ -174,7 +174,7 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
@override_config({"experimental_features": {"msc3244_enabled": False}})
|
||||
def test_get_does_not_include_msc3244_fields_when_disabled(self):
|
||||
access_token = self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
@ -189,7 +189,7 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
def test_get_does_include_msc3244_fields_when_enabled(self):
|
||||
access_token = self.get_success(
|
||||
self.auth_handler.get_access_token_for_user_id(
|
||||
self.auth_handler.create_access_token_for_user_id(
|
||||
self.user, device_id=None, valid_until_ms=None
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue