0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-03 21:28:57 +01:00

Better logging when login can't find a 3pid

This commit is contained in:
Richard van der Hoff 2017-12-20 19:31:00 +00:00
parent 3f9f1c50f3
commit 75c1b8df01

View file

@ -191,19 +191,25 @@ class LoginRestServlet(ClientV1RestServlet):
# convert threepid identifiers to user IDs # convert threepid identifiers to user IDs
if identifier["type"] == "m.id.thirdparty": if identifier["type"] == "m.id.thirdparty":
if 'medium' not in identifier or 'address' not in identifier: address = identifier.get('address')
medium = identifier.get('medium')
if medium is None or address is None:
raise SynapseError(400, "Invalid thirdparty identifier") raise SynapseError(400, "Invalid thirdparty identifier")
address = identifier['address'] if medium == 'email':
if identifier['medium'] == 'email':
# For emails, transform the address to lowercase. # For emails, transform the address to lowercase.
# We store all email addreses as lowercase in the DB. # We store all email addreses as lowercase in the DB.
# (See add_threepid in synapse/handlers/auth.py) # (See add_threepid in synapse/handlers/auth.py)
address = address.lower() address = address.lower()
user_id = yield self.hs.get_datastore().get_user_id_by_threepid( user_id = yield self.hs.get_datastore().get_user_id_by_threepid(
identifier['medium'], address medium, address,
) )
if not user_id: if not user_id:
logger.warn(
"unknown 3pid identifier medium %s, address %r",
medium, address,
)
raise LoginError(403, "", errcode=Codes.FORBIDDEN) raise LoginError(403, "", errcode=Codes.FORBIDDEN)
identifier = { identifier = {