Update SFJS to include authentication locking, lock authentication UI after submit

This commit is contained in:
Mo Bitar
2018-10-13 14:43:25 -05:00
parent d226be41b7
commit 00dd21179f
4 changed files with 12 additions and 6 deletions

View File

@@ -66,6 +66,7 @@ class AccountMenu {
syncManager.lockSyncing(); syncManager.lockSyncing();
$scope.formData.status = "Generating Login Keys..."; $scope.formData.status = "Generating Login Keys...";
$scope.formData.authenticating = true;
$timeout(function(){ $timeout(function(){
authManager.login($scope.formData.url, $scope.formData.email, $scope.formData.user_password, authManager.login($scope.formData.url, $scope.formData.email, $scope.formData.user_password,
$scope.formData.ephemeral, $scope.formData.strictSignin, extraParams).then((response) => { $scope.formData.ephemeral, $scope.formData.strictSignin, extraParams).then((response) => {
@@ -88,6 +89,8 @@ class AccountMenu {
$scope.formData.mfa = null; $scope.formData.mfa = null;
if(error.message) { alert(error.message); } if(error.message) { alert(error.message); }
} }
$scope.formData.authenticating = false;
} }
// Success // Success
else { else {
@@ -110,6 +113,7 @@ class AccountMenu {
$scope.formData.confirmPassword = false; $scope.formData.confirmPassword = false;
$scope.formData.status = "Generating Account Keys..."; $scope.formData.status = "Generating Account Keys...";
$scope.formData.authenticating = true;
$timeout(function(){ $timeout(function(){
authManager.register($scope.formData.url, $scope.formData.email, $scope.formData.user_password, $scope.formData.ephemeral).then((response) => { authManager.register($scope.formData.url, $scope.formData.email, $scope.formData.user_password, $scope.formData.ephemeral).then((response) => {
@@ -117,6 +121,7 @@ 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."}
$scope.formData.authenticating = false;
alert(error.message); alert(error.message);
} else { } else {
$scope.onAuthSuccess(() => { $scope.onAuthSuccess(() => {
@@ -139,6 +144,7 @@ class AccountMenu {
$scope.onAuthSuccess = function(callback) { $scope.onAuthSuccess = function(callback) {
var block = function() { var block = function() {
$timeout(function(){ $timeout(function(){
$scope.formData.authenticating = false;
$scope.onSuccessfulAuth()(); $scope.onSuccessfulAuth()();
syncManager.refreshErroredItems(); syncManager.refreshErroredItems();
callback && callback(); callback && callback();

View File

@@ -45,7 +45,7 @@
%a{"href" => "https://standardnotes.org/help/security", "target" => "_blank"} (Learn more) %a{"href" => "https://standardnotes.org/help/security", "target" => "_blank"} (Learn more)
.button-group.stretch.panel-row.form-submit .button-group.stretch.panel-row.form-submit
%button.button.info.featured{"type" => "submit"} %button.button.info.featured{"type" => "submit", "ng-disabled" => "formData.authenticating"}
.label {{formData.showLogin ? "Sign In" : "Register"}} .label {{formData.showLogin ? "Sign In" : "Register"}}
%label %label

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "standard-notes-web", "name": "standard-notes-web",
"version": "2.3.11", "version": "2.3.13",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -8006,9 +8006,9 @@
"dev": true "dev": true
}, },
"standard-file-js": { "standard-file-js": {
"version": "0.3.16", "version": "0.3.17",
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.16.tgz", "resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.17.tgz",
"integrity": "sha512-xCyEABG6+JE09A6jZJW49QczNntAtYvN3DQXMPu1PiaiFFYinBXYMmMdGKAAgH+a2T2w0UzB6mrMCjCMuz+tYw==", "integrity": "sha512-YeX33yz19TB+JrkCWigO21Tugw6oVRi2s8m0lHG0JSOPr4UNA7ufdbzcFgQyDbh6UvF6eCevb1uezt3A3nejmQ==",
"dev": true "dev": true
}, },
"static-extend": { "static-extend": {

View File

@@ -39,7 +39,7 @@
"karma-jasmine": "^1.1.0", "karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.2", "karma-phantomjs-launcher": "^1.0.2",
"sn-stylekit": "1.0.15", "sn-stylekit": "1.0.15",
"standard-file-js": "0.3.16", "standard-file-js": "0.3.17",
"sn-models": "0.1.9", "sn-models": "0.1.9",
"connect": "^3.6.6", "connect": "^3.6.6",
"mocha": "^5.2.0", "mocha": "^5.2.0",