Auth error handling for non-json responses
This commit is contained in:
@@ -101,7 +101,10 @@ angular.module('app.frontend')
|
|||||||
callback(response);
|
callback(response);
|
||||||
}, function(response){
|
}, function(response){
|
||||||
console.error("Error getting auth params", response);
|
console.error("Error getting auth params", response);
|
||||||
callback(null);
|
if(typeof response !== 'object') {
|
||||||
|
response = {error: {message: "A server error occurred while trying to sign in. Please try again."}};
|
||||||
|
}
|
||||||
|
callback(response);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +123,11 @@ angular.module('app.frontend')
|
|||||||
this.login = function(url, email, password, ephemeral, callback) {
|
this.login = function(url, email, password, ephemeral, callback) {
|
||||||
this.getAuthParamsForEmail(url, email, function(authParams){
|
this.getAuthParamsForEmail(url, email, function(authParams){
|
||||||
|
|
||||||
|
if(authParams.error) {
|
||||||
|
callback(authParams);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!authParams || !authParams.pw_cost) {
|
if(!authParams || !authParams.pw_cost) {
|
||||||
callback({error : {message: "Invalid email or password."}});
|
callback({error : {message: "Invalid email or password."}});
|
||||||
return;
|
return;
|
||||||
@@ -158,6 +166,9 @@ angular.module('app.frontend')
|
|||||||
callback(response);
|
callback(response);
|
||||||
}.bind(this), function(response){
|
}.bind(this), function(response){
|
||||||
console.error("Error logging in", response);
|
console.error("Error logging in", response);
|
||||||
|
if(typeof response !== 'object') {
|
||||||
|
response = {error: {message: "A server error occurred while trying to sign in. Please try again."}};
|
||||||
|
}
|
||||||
callback(response);
|
callback(response);
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -199,10 +210,12 @@ angular.module('app.frontend')
|
|||||||
httpManager.postAbsolute(requestUrl, params, function(response){
|
httpManager.postAbsolute(requestUrl, params, function(response){
|
||||||
this.setEphemeral(ephemeral);
|
this.setEphemeral(ephemeral);
|
||||||
this.handleAuthResponse(response, email, url, authParams, keys);
|
this.handleAuthResponse(response, email, url, authParams, keys);
|
||||||
|
|
||||||
callback(response);
|
callback(response);
|
||||||
}.bind(this), function(response){
|
}.bind(this), function(response){
|
||||||
console.error("Registration error", response);
|
console.error("Registration error", response);
|
||||||
|
if(typeof response !== 'object') {
|
||||||
|
response = {error: {message: "A server error occurred while trying to register. Please try again."}};
|
||||||
|
}
|
||||||
callback(response);
|
callback(response);
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|||||||
Reference in New Issue
Block a user