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

Fix JWT login with new users #5586

Merged
merged 3 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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