Skip to content
Snippets Groups Projects
Commit fb93e14e authored by Kegan Dougal's avatar Kegan Dougal
Browse files

Be more helpful when failing to register/login, stating why (communication...

Be more helpful when failing to register/login, stating why (communication error, user in user, wrong credentials, etc). Make the HS send M_USER_IN_USE.
parent 40c99833
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ from twisted.internet import defer ...@@ -17,7 +17,7 @@ from twisted.internet import defer
from sqlite3 import IntegrityError from sqlite3 import IntegrityError
from synapse.api.errors import StoreError from synapse.api.errors import StoreError, Codes
from ._base import SQLBaseStore from ._base import SQLBaseStore
...@@ -73,7 +73,7 @@ class RegistrationStore(SQLBaseStore): ...@@ -73,7 +73,7 @@ class RegistrationStore(SQLBaseStore):
"VALUES (?,?,?)", "VALUES (?,?,?)",
[user_id, password_hash, now]) [user_id, password_hash, now])
except IntegrityError: except IntegrityError:
raise StoreError(400, "User ID already taken.") raise StoreError(400, "User ID already taken.", errcode=Codes.USER_IN_USE)
# it's possible for this to get a conflict, but only for a single user # it's possible for this to get a conflict, but only for a single user
# since tokens are namespaced based on their user ID # since tokens are namespaced based on their user ID
......
...@@ -55,8 +55,15 @@ angular.module('LoginController', ['matrixService']) ...@@ -55,8 +55,15 @@ angular.module('LoginController', ['matrixService'])
// Go to the user's rooms list page // Go to the user's rooms list page
$location.path("rooms"); $location.path("rooms");
}, },
function(reason) { function(error) {
$scope.feedback = "Failure: " + reason; if (error.data) {
if (error.data.errcode === "M_USER_IN_USE") {
$scope.feedback = "Username already taken.";
}
}
else if (error.status === 0) {
$scope.feedback = "Unable to talk to the server.";
}
}); });
}; };
...@@ -83,8 +90,13 @@ angular.module('LoginController', ['matrixService']) ...@@ -83,8 +90,13 @@ angular.module('LoginController', ['matrixService'])
} }
}, },
function(error) { function(error) {
if (error.data.errcode === "M_FORBIDDEN") { if (error.data) {
$scope.login_error_msg = "Incorrect username or password."; if (error.data.errcode === "M_FORBIDDEN") {
$scope.login_error_msg = "Incorrect username or password.";
}
}
else if (error.status === 0) {
$scope.login_error_msg = "Unable to talk to the server.";
} }
} }
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment