summary refs log tree commit diff
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-14 16:29:24 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-14 16:29:51 +0100
commitca3747fb2f9a1e2e6d5d9e55cd0760e373b57a90 (patch)
tree2c5c9e9a4d8844ad32f600af48a5c48e6c2c4576
parentReflect user's messages up to themselves before pushing it to federatoin; als... (diff)
downloadsynapse-ca3747fb2f9a1e2e6d5d9e55cd0760e373b57a90.tar.xz
hs: Make /login accept full user IDs or just local parts. webclient: Only enable Register button when both password fields match.
-rw-r--r--synapse/handlers/login.py6
-rw-r--r--webclient/login/login-controller.js6
-rw-r--r--webclient/login/login.html2
3 files changed, 6 insertions, 8 deletions
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:
diff --git a/webclient/login/login-controller.js b/webclient/login/login-controller.js
index 826a533873..53756be9ea 100644
--- a/webclient/login/login-controller.js
+++ b/webclient/login/login-controller.js
@@ -68,12 +68,6 @@ angular.module('LoginController', ['matrixService'])
     };
 
     $scope.login = function() {
-        if ($scope.account.user_id.indexOf("@") !== 0) {
-            // technically should be the host of account.homeserver
-            $scope.account.user_id = "@" + $scope.account.user_id + ":" + 
-                                     $location.host()
-        }
-    
         matrixService.setConfig({
             homeserver: $scope.account.homeserver,
             user_id: $scope.account.user_id
diff --git a/webclient/login/login.html b/webclient/login/login.html
index f02dde89a6..0fbeeabed7 100644
--- a/webclient/login/login.html
+++ b/webclient/login/login.html
@@ -15,7 +15,7 @@
         <!-- New user registration -->
         <div>
             <br/>
-            <button ng-click="register()" ng-disabled="!account.desired_user_name || !account.homeserver || !account.identityServer || !account.pwd1 || !account.pwd2">Register</button>
+            <button ng-click="register()" ng-disabled="!account.desired_user_name || !account.homeserver || !account.identityServer || !account.pwd1 || !account.pwd2 || account.pwd1 !== account.pwd2">Register</button>
         </div>
     </form>