hs: Make /login accept full user IDs or just local parts. webclient: Only enable Register button when both password fields match.

This commit is contained in:
Kegan Dougal 2014-08-14 16:29:24 +01:00
parent 53147e5ae4
commit ca3747fb2f
3 changed files with 6 additions and 8 deletions

View File

@ -16,6 +16,7 @@
from twisted.internet import defer from twisted.internet import defer
from ._base import BaseHandler from ._base import BaseHandler
from synapse.types import UserID
from synapse.api.errors import LoginError, Codes from synapse.api.errors import LoginError, Codes
import bcrypt import bcrypt
@ -35,7 +36,7 @@ class LoginHandler(BaseHandler):
"""Login as the specified user with the specified password. """Login as the specified user with the specified password.
Args: Args:
user (str): The user ID. user (str): The user ID or username.
password (str): The password. password (str): The password.
Returns: Returns:
The newly allocated access token. The newly allocated access token.
@ -47,6 +48,9 @@ class LoginHandler(BaseHandler):
if not hasattr(self, "reg_handler"): if not hasattr(self, "reg_handler"):
self.reg_handler = self.hs.get_handlers().registration_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 # pull out the hash for this user if they exist
user_info = yield self.store.get_user_by_id(user_id=user) user_info = yield self.store.get_user_by_id(user_id=user)
if not user_info: if not user_info:

View File

@ -68,12 +68,6 @@ angular.module('LoginController', ['matrixService'])
}; };
$scope.login = function() { $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({ matrixService.setConfig({
homeserver: $scope.account.homeserver, homeserver: $scope.account.homeserver,
user_id: $scope.account.user_id user_id: $scope.account.user_id

View File

@ -15,7 +15,7 @@
<!-- New user registration --> <!-- New user registration -->
<div> <div>
<br/> <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> </div>
</form> </form>