Password wizard lock continue, SFJS 0.3.18
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user