Password wizard lock continue, SFJS 0.3.18

This commit is contained in:
Mo Bitar
2018-10-14 13:31:14 -05:00
parent 39a3b80b96
commit 755ecd6fb5
4 changed files with 36 additions and 6 deletions

View File

@@ -15,7 +15,20 @@ class PasswordWizard {
controller($scope, modelManager, archiveManager, authManager, syncManager, $timeout) {
'ngInject';
window.onbeforeunload = (e) => {
// Confirms with user to close tab before closing
return true;
};
$scope.$on("$destroy", function() {
window.onbeforeunload = null;
});
$scope.dismiss = function() {
if($scope.lockContinue) {
alert("Cannot close window until pending tasks are complete.");
return;
}
$scope.el.remove();
$scope.$destroy();
}
@@ -64,6 +77,15 @@ class PasswordWizard {
$scope.continue = function() {
if($scope.lockContinue || $scope.isContinuing) {
return;
}
// isContinuing is a way to lock the continue function separate from lockContinue
// lockContinue can be locked by other places, but isContinuing is only lockable from within this function.
$scope.isContinuing = true;
if($scope.step == FinishStep) {
$scope.dismiss();
return;
@@ -72,6 +94,8 @@ class PasswordWizard {
let next = () => {
$scope.step += 1;
$scope.initializeStep($scope.step);
$scope.isContinuing = false;
}
var preprocessor = $scope.preprocessorForStep($scope.step);
@@ -151,8 +175,15 @@ class PasswordWizard {
let currentPassword = $scope.formData.currentPassword;
let newPass = $scope.securityUpdate ? currentPassword : $scope.formData.newPassword;
if(!currentPassword || currentPassword.length == 0) {
alert("Please enter your current password.");
callback(false);
return;
}
if($scope.changePassword) {
if(!newPass || newPass.length == 0) {
alert("Please enter a new password.");
callback(false);
return;
}

View File

@@ -72,7 +72,6 @@
.panel-column.stretch
%form
%input.form-control{:type => 'password', "ng-model" => "formData.currentPassword", "placeholder" => "Current Password", "sn-autofocus" => "true", "should-focus" => "true"}
%input.form-control{"ng-if" => "changePassword", :type => 'password', "ng-model" => "formData.newPassword", "placeholder" => "New Password"}
%input.form-control{"ng-if" => "changePassword", :type => 'password', "ng-model" => "formData.newPasswordConfirmation", "placeholder" => "Confirm New Password"}
@@ -104,6 +103,6 @@
.footer
.empty
%a.right{"ng-click" => "continue()", "ng-class" => "{'disabled' : lockContinue}"}
%a.right{"ng-click" => "continue()", "ng-disabled" => "lockContinue", "ng-class" => "{'disabled' : lockContinue}"}
.spinner.small.inline.info.mr-5{"ng-if" => "showSpinner"}
{{continueTitle}}

6
package-lock.json generated
View File

@@ -8006,9 +8006,9 @@
"dev": true
},
"standard-file-js": {
"version": "0.3.17",
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.17.tgz",
"integrity": "sha512-YeX33yz19TB+JrkCWigO21Tugw6oVRi2s8m0lHG0JSOPr4UNA7ufdbzcFgQyDbh6UvF6eCevb1uezt3A3nejmQ==",
"version": "0.3.18",
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.18.tgz",
"integrity": "sha512-5EyOohX7qTZ5zmbnPP0L1bA07SZCd6U0wKEx9j5JXUT5xF2YVDc6clV4kkAmsXAwoMIGZQIs4x2Nvqc5ka4nCQ==",
"dev": true
},
"static-extend": {

View File

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