mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Merge pull request #251 from matrix-org/removeadmin
Stop looking up "admin", which we never read
This commit is contained in:
commit
a2355fae7e
@ -392,8 +392,7 @@ class Auth(object):
|
|||||||
Args:
|
Args:
|
||||||
token (str): The access token to get the user by.
|
token (str): The access token to get the user by.
|
||||||
Returns:
|
Returns:
|
||||||
dict : dict that includes the user and whether the
|
dict : dict that includes the user and the ID of their access token.
|
||||||
user is a server admin.
|
|
||||||
Raises:
|
Raises:
|
||||||
AuthError if no user by that token exists or the token is invalid.
|
AuthError if no user by that token exists or the token is invalid.
|
||||||
"""
|
"""
|
||||||
@ -404,7 +403,6 @@ class Auth(object):
|
|||||||
errcode=Codes.UNKNOWN_TOKEN
|
errcode=Codes.UNKNOWN_TOKEN
|
||||||
)
|
)
|
||||||
user_info = {
|
user_info = {
|
||||||
"admin": bool(ret.get("admin", False)),
|
|
||||||
"user": UserID.from_string(ret.get("name")),
|
"user": UserID.from_string(ret.get("name")),
|
||||||
"token_id": ret.get("token_id", None),
|
"token_id": ret.get("token_id", None),
|
||||||
}
|
}
|
||||||
|
@ -163,8 +163,7 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
Args:
|
Args:
|
||||||
token (str): The access token of a user.
|
token (str): The access token of a user.
|
||||||
Returns:
|
Returns:
|
||||||
dict: Including the name (user_id) and whether they are
|
dict: Including the name (user_id) and the ID of their access token.
|
||||||
an admin.
|
|
||||||
Raises:
|
Raises:
|
||||||
StoreError if no user was found.
|
StoreError if no user was found.
|
||||||
"""
|
"""
|
||||||
@ -228,7 +227,7 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
|
|
||||||
def _query_for_auth(self, txn, token):
|
def _query_for_auth(self, txn, token):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT users.name, users.admin, access_tokens.id as token_id"
|
"SELECT users.name, access_tokens.id as token_id"
|
||||||
" FROM users"
|
" FROM users"
|
||||||
" INNER JOIN access_tokens on users.name = access_tokens.user_id"
|
" INNER JOIN access_tokens on users.name = access_tokens.user_id"
|
||||||
" WHERE token = ?"
|
" WHERE token = ?"
|
||||||
|
@ -41,7 +41,6 @@ class AuthTestCase(unittest.TestCase):
|
|||||||
user_info = {
|
user_info = {
|
||||||
"name": self.test_user,
|
"name": self.test_user,
|
||||||
"token_id": "ditto",
|
"token_id": "ditto",
|
||||||
"admin": False
|
|
||||||
}
|
}
|
||||||
self.store.get_user_by_access_token = Mock(return_value=user_info)
|
self.store.get_user_by_access_token = Mock(return_value=user_info)
|
||||||
|
|
||||||
@ -66,7 +65,6 @@ class AuthTestCase(unittest.TestCase):
|
|||||||
user_info = {
|
user_info = {
|
||||||
"name": self.test_user,
|
"name": self.test_user,
|
||||||
"token_id": "ditto",
|
"token_id": "ditto",
|
||||||
"admin": False
|
|
||||||
}
|
}
|
||||||
self.store.get_user_by_access_token = Mock(return_value=user_info)
|
self.store.get_user_by_access_token = Mock(return_value=user_info)
|
||||||
|
|
||||||
|
@ -73,7 +73,6 @@ class PresenceStateTestCase(unittest.TestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(myid),
|
"user": UserID.from_string(myid),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +160,6 @@ class PresenceListTestCase(unittest.TestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(myid),
|
"user": UserID.from_string(myid),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ class RoomPermissionsTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
||||||
@ -443,7 +442,6 @@ class RoomsMemberListTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
||||||
@ -522,7 +520,6 @@ class RoomsCreateTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
||||||
@ -614,7 +611,6 @@ class RoomTopicTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +716,6 @@ class RoomMemberStateTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
||||||
@ -846,7 +841,6 @@ class RoomMessagesTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
||||||
@ -942,7 +936,6 @@ class RoomInitialSyncTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
|
||||||
|
@ -64,7 +64,6 @@ class RoomTypingTestCase(RestTestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.auth_user_id),
|
"user": UserID.from_string(self.auth_user_id),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ class V2AlphaRestTestCase(unittest.TestCase):
|
|||||||
def _get_user_by_access_token(token=None):
|
def _get_user_by_access_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(self.USER_ID),
|
"user": UserID.from_string(self.USER_ID),
|
||||||
"admin": False,
|
|
||||||
"token_id": 1,
|
"token_id": 1,
|
||||||
}
|
}
|
||||||
hs.get_auth().get_user_by_access_token = _get_user_by_access_token
|
hs.get_auth().get_user_by_access_token = _get_user_by_access_token
|
||||||
|
@ -53,7 +53,6 @@ class RegistrationStoreTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
{
|
{
|
||||||
"admin": 0,
|
|
||||||
"name": self.user_id,
|
"name": self.user_id,
|
||||||
},
|
},
|
||||||
result
|
result
|
||||||
@ -70,7 +69,6 @@ class RegistrationStoreTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
{
|
{
|
||||||
"admin": 0,
|
|
||||||
"name": self.user_id,
|
"name": self.user_id,
|
||||||
},
|
},
|
||||||
result
|
result
|
||||||
|
@ -281,7 +281,6 @@ class MemoryDataStore(object):
|
|||||||
try:
|
try:
|
||||||
return {
|
return {
|
||||||
"name": self.tokens_to_users[token],
|
"name": self.tokens_to_users[token],
|
||||||
"admin": 0,
|
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
raise StoreError(400, "User does not exist.")
|
raise StoreError(400, "User does not exist.")
|
||||||
|
Loading…
Reference in New Issue
Block a user