Login improved error handling

This commit is contained in:
Mo Bitar
2018-02-07 09:55:28 -06:00
parent 1a1ead9786
commit c15bdda6c9
2 changed files with 17 additions and 10 deletions

View File

@@ -110,19 +110,27 @@ class AccountMenu {
if(!response || response.error) { if(!response || response.error) {
$scope.formData.status = null; $scope.formData.status = null;
var error = response ? response.error : {message: "An unknown error occured."} var error = response ? response.error : {message: "An unknown error occured."}
// MFA Error
if(error.tag == "mfa-required" || error.tag == "mfa-invalid") { if(error.tag == "mfa-required" || error.tag == "mfa-invalid") {
$timeout(() => { $timeout(() => {
$scope.formData.showLogin = false; $scope.formData.showLogin = false;
$scope.formData.mfa = error; $scope.formData.mfa = error;
}) })
} else if(!response || (response && !response.didDisplayAlert)) { }
// General Error
else {
$timeout(() => { $timeout(() => {
$scope.formData.showLogin = true; $scope.formData.showLogin = true;
$scope.formData.mfa = null; $scope.formData.mfa = null;
}) })
alert(error.message); alert(error.message);
} }
} else { }
// Success
else {
$scope.onAuthSuccess(); $scope.onAuthSuccess();
} }
}); });

View File

@@ -133,24 +133,23 @@ angular.module('app')
} }
if(!this.isProtocolVersionSupported(authParams.version)) { if(!this.isProtocolVersionSupported(authParams.version)) {
alert("The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.org/help/security-update for more information."); let message = "The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.org/help/security-update for more information.";
callback({didDisplayAlert: true}); callback({error: {message: message}});
return; return;
} }
if(!this.supportsPasswordDerivationCost(authParams.pw_cost)) { if(!this.supportsPasswordDerivationCost(authParams.pw_cost)) {
var string = "Your account was created on a platform with higher security capabilities than this browser supports. " + let message = "Your account was created on a platform with higher security capabilities than this browser supports. " +
"If we attempted to generate your login keys here, it would take hours. " + "If we attempted to generate your login keys here, it would take hours. " +
"Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to login." "Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in."
alert(string) callback({error: {message: message}});
callback({didDisplayAlert: true});
return; return;
} }
var minimum = this.costMinimumForVersion(authParams.version); var minimum = this.costMinimumForVersion(authParams.version);
if(authParams.pw_cost < minimum) { if(authParams.pw_cost < minimum) {
alert("Unable to login due to insecure password parameters. Please visit standardnotes.org/help/password-upgrade for more information."); let message = "Unable to login due to insecure password parameters. Please visit standardnotes.org/help/password-upgrade for more information.";
callback({didDisplayAlert: true}); callback({error: {message: message}});
return; return;
} }