Fix JWT login with new users ()

Signed-off-by: Pau Rodriguez-Estivill <prodrigestivill@gmail.com>
This commit is contained in:
PauRE 2019-07-02 11:25:37 +02:00 committed by Richard van der Hoff
parent b4914681a5
commit 948488e115
2 changed files with 4 additions and 6 deletions
changelog.d
synapse/rest/client/v1

1
changelog.d/5586.bugfix Normal file
View File

@ -0,0 +1 @@
Fixed m.login.jwt using unregistred user_id and added pyjwt>=1.6.4 as jwt conditional dependencies. Contributed by Pau Rodriguez-Estivill.

View File

@ -319,12 +319,12 @@ class LoginRestServlet(RestServlet):
raise LoginError(401, "Invalid JWT", errcode=Codes.UNAUTHORIZED) raise LoginError(401, "Invalid JWT", errcode=Codes.UNAUTHORIZED)
user_id = UserID(user, self.hs.hostname).to_string() user_id = UserID(user, self.hs.hostname).to_string()
device_id = login_submission.get("device_id")
initial_display_name = login_submission.get("initial_device_display_name")
auth_handler = self.auth_handler auth_handler = self.auth_handler
registered_user_id = yield auth_handler.check_user_exists(user_id) registered_user_id = yield auth_handler.check_user_exists(user_id)
if registered_user_id: if registered_user_id:
device_id = login_submission.get("device_id")
initial_display_name = login_submission.get("initial_device_display_name")
device_id, access_token = yield self.registration_handler.register_device( device_id, access_token = yield self.registration_handler.register_device(
registered_user_id, device_id, initial_display_name registered_user_id, device_id, initial_display_name
) )
@ -338,11 +338,8 @@ class LoginRestServlet(RestServlet):
user_id, access_token = ( user_id, access_token = (
yield self.registration_handler.register(localpart=user) yield self.registration_handler.register(localpart=user)
) )
device_id = login_submission.get("device_id")
initial_display_name = login_submission.get("initial_device_display_name")
device_id, access_token = yield self.registration_handler.register_device( device_id, access_token = yield self.registration_handler.register_device(
registered_user_id, device_id, initial_display_name user_id, device_id, initial_display_name
) )
result = { result = {