From ca3747fb2f9a1e2e6d5d9e55cd0760e373b57a90 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 14 Aug 2014 16:29:24 +0100 Subject: hs: Make /login accept full user IDs or just local parts. webclient: Only enable Register button when both password fields match. --- synapse/handlers/login.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'synapse') diff --git a/synapse/handlers/login.py b/synapse/handlers/login.py index 0220fa0604..5c7d503a24 100644 --- a/synapse/handlers/login.py +++ b/synapse/handlers/login.py @@ -16,6 +16,7 @@ from twisted.internet import defer from ._base import BaseHandler +from synapse.types import UserID from synapse.api.errors import LoginError, Codes import bcrypt @@ -35,7 +36,7 @@ class LoginHandler(BaseHandler): """Login as the specified user with the specified password. Args: - user (str): The user ID. + user (str): The user ID or username. password (str): The password. Returns: The newly allocated access token. @@ -47,6 +48,9 @@ class LoginHandler(BaseHandler): if not hasattr(self, "reg_handler"): self.reg_handler = self.hs.get_handlers().registration_handler + if not user.startswith('@'): + user = UserID.create_local(user, self.hs).to_string() + # pull out the hash for this user if they exist user_info = yield self.store.get_user_by_id(user_id=user) if not user_info: -- cgit 1.4.1