summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2012-11-20 10:52:45 +0100
committerAzul <azul@riseup.net>2012-11-20 10:52:45 +0100
commitcb46537c98db3cb7ac8cf23de243a86aa4a36acd (patch)
tree63cba32a93535d5cfe776d5fc0861f7ba3dcff6f
parent555491c4420a3b8b23b74fb081b76a5bf7778049 (diff)
sending the parsed json object to the error handler
-rw-r--r--spec/login_spec.js2
-rw-r--r--src/jqueryRest.js12
2 files changed, 10 insertions, 4 deletions
diff --git a/spec/login_spec.js b/spec/login_spec.js
index da343a5..16a63d0 100644
--- a/spec/login_spec.js
+++ b/spec/login_spec.js
@@ -64,7 +64,7 @@ describe("Login with srp var", function() {
expect(srp.error).toHaveBeenCalled;
var args = srp.error.args[0];
- expect($.parseJSON(args[0].responseText)).toEqual(error);
+ expect(args[0]).toEqual(error);
});
it("rejects B = 0", function(){
diff --git a/src/jqueryRest.js b/src/jqueryRest.js
index c439f67..c4b0161 100644
--- a/src/jqueryRest.js
+++ b/src/jqueryRest.js
@@ -29,13 +29,13 @@ srp.remote = (function(){
function signup(){
jqueryRest.register(srp.session)
.success(srp.signedUp)
- .error(srp.error)
+ .error(error)
};
function login(){
jqueryRest.handshake(srp.session)
.success(receiveSalts)
- .error(srp.error)
+ .error(error)
};
function receiveSalts(response){
@@ -52,7 +52,7 @@ srp.remote = (function(){
srp.session.calculations(response.salt, response.B);
jqueryRest.authenticate(srp.session)
.success(confirmAuthentication)
- .error(srp.error);
+ .error(error);
}
};
@@ -66,6 +66,12 @@ srp.remote = (function(){
srp.error("Server key does not match");
};
+ // The server will send error messages as json alongside
+ // the http error response.
+ function error(xhr)
+ {
+ srp.error($.parseJSON(xhr.responseText))
+ };
return {
signup: signup,