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

Commit

Permalink
Fix JWT login with new users (#5586)
Browse files Browse the repository at this point in the history
Signed-off-by: Pau Rodriguez-Estivill <prodrigestivill@gmail.com>
  • Loading branch information
prodrigestivill authored and richvdh committed Jul 2, 2019
1 parent b491468 commit 948488e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/5586.bugfix
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 3 additions & 6 deletions synapse/rest/client/v1/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ def do_jwt_login(self, login_submission):
raise LoginError(401, "Invalid JWT", errcode=Codes.UNAUTHORIZED)

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
registered_user_id = yield auth_handler.check_user_exists(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(
registered_user_id, device_id, initial_display_name
)
Expand All @@ -338,11 +338,8 @@ def do_jwt_login(self, login_submission):
user_id, access_token = (
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(
registered_user_id, device_id, initial_display_name
user_id, device_id, initial_display_name
)

result = {
Expand Down

0 comments on commit 948488e

Please sign in to comment.