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

Support logging in with email addresses (or other threepids) #234

Merged
merged 3 commits into from
Aug 20, 2015
Merged
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
17 changes: 12 additions & 5 deletions synapse/rest/client/v1/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,23 @@ def on_POST(self, request):

@defer.inlineCallbacks
def do_password_login(self, login_submission):
if not login_submission["user"].startswith('@'):
login_submission["user"] = UserID.create(
login_submission["user"], self.hs.hostname).to_string()
if 'medium' in login_submission and 'address' in login_submission:
user_id = yield self.hs.get_datastore().get_user_id_by_threepid(
login_submission['medium'], login_submission['address']
)
else:
user_id = login_submission['user']

if not user_id.startswith('@'):
user_id = UserID.create(
user_id, self.hs.hostname).to_string()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I prefer to put the closing brace on a new line, especially when appending further function calls

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too, but this is how it was before.


token = yield self.handlers.auth_handler.login_with_password(
user_id=login_submission["user"],
user_id=user_id,
password=login_submission["password"])

result = {
"user_id": login_submission["user"], # may have changed
"user_id": user_id, # may have changed
"access_token": token,
"home_server": self.hs.hostname,
}
Expand Down