solid password change

This commit is contained in:
Mo Bitar
2017-02-10 13:10:19 -06:00
parent 577f286352
commit 5d6d594b6c
4 changed files with 45 additions and 37 deletions

View File

@@ -20,11 +20,15 @@ angular
});
function showSpinner() {
if(scope.hidePromise) {
$timeout.cancel(scope.hidePromise);
scope.hidePromise = null;
}
showElement(true);
}
function hideSpinner() {
$timeout(showElement.bind(this, false), getDelay());
scope.hidePromise = $timeout(showElement.bind(this, false), getDelay());
}
function showElement(show) {

View File

@@ -30,7 +30,7 @@ class AccountMenu {
$scope.newPasswordData = {};
$scope.showPasswordChangeForm = function() {
$scope.newPasswordData.showNewPasswordForm = true;
$scope.newPasswordData.showForm = true;
}
$scope.submitPasswordChange = function() {
@@ -49,29 +49,35 @@ class AccountMenu {
}
$scope.newPasswordData.status = "Generating New Keys...";
$scope.newPasswordData.showForm = false;
authManager.changePassword(email, $scope.newPasswordData.newPassword, function(response){
if(response.error) {
alert("There was an error changing your password. Please try again.");
$scope.newPasswordData.status = null;
return;
}
// re-encrypt all items
$scope.newPasswordData.status = "Re-encrypting all items with your new key...";
modelManager.setAllItemsDirty();
syncManager.sync(function(response){
// perform a sync beforehand to pull in any last minutes changes before we change the encryption key (and thus cant decrypt new changes)
syncManager.sync(function(response){
authManager.changePassword(email, $scope.newPasswordData.newPassword, function(response){
if(response.error) {
alert("There was an error re-encrypting your items. Your password was changed, but not all your items were properly re-encrypted and synced. You should try syncing again. If all else fails, you should restore your notes from backup.")
alert("There was an error changing your password. Please try again.");
$scope.newPasswordData.status = null;
return;
}
$scope.newPasswordData.status = "Successfully changed password and re-encrypted all items.";
alert("Your password has been changed, and your items successfully re-encrypted and synced. Be sure to log out on all other signed in applications.")
$timeout(function(){
$scope.newPasswordData = {};
}, 1000)
});
// re-encrypt all items
$scope.newPasswordData.status = "Re-encrypting all items with your new key...";
modelManager.setAllItemsDirty();
syncManager.sync(function(response){
if(response.error) {
alert("There was an error re-encrypting your items. Your password was changed, but not all your items were properly re-encrypted and synced. You should try syncing again. If all else fails, you should restore your notes from backup.")
return;
}
$scope.newPasswordData.status = "Successfully changed password and re-encrypted all items.";
$timeout(function(){
alert("Your password has been changed, and your items successfully re-encrypted and synced. You must sign out on all other signed in applications and sign in again, or else you may corrupt your data.")
$scope.newPasswordData = {};
}, 1000)
});
})
})
}
$scope.loginSubmitPressed = function() {

View File

@@ -115,7 +115,6 @@ class SyncManager {
allCallbacks.push(currentCallback);
}
if(allCallbacks.length) {
console.log(allCallbacks.length, "queued callbacks");
for(var eachCallback of allCallbacks) {
eachCallback(response);
}
@@ -144,7 +143,7 @@ class SyncManager {
return;
}
var isContinuationSync = this.needsMoreSync;
var isContinuationSync = this.syncStatus.needsMoreSync;
this.syncStatus.syncOpInProgress = true;
@@ -152,9 +151,9 @@ class SyncManager {
var subItems = allDirtyItems.slice(0, submitLimit);
if(subItems.length < allDirtyItems.length) {
// more items left to be synced, repeat
this.needsMoreSync = true;
this.syncStatus.needsMoreSync = true;
} else {
this.needsMoreSync = false;
this.syncStatus.needsMoreSync = false;
}
if(!isContinuationSync) {
@@ -199,14 +198,14 @@ class SyncManager {
this.syncToken = response.sync_token;
this.cursorToken = response.cursor_token;
if(this.cursorToken || this.needsMoreSync) {
if(this.cursorToken || this.syncStatus.needsMoreSync) {
setTimeout(function () {
this.sync(callback, options);
}.bind(this), 10); // wait 10ms to allow UI to update
} else if(this.repeatOnCompletion) {
this.repeatOnCompletion = false;
setTimeout(function () {
this.sync(null, options);
this.sync(callback, options);
}.bind(this), 10); // wait 10ms to allow UI to update
} else {
this.callQueuedCallbacksAndCurrent(callback, response);
@@ -242,7 +241,7 @@ class SyncManager {
var item = this.modelManager.findItem(itemResponse.uuid);
var error = mapping.error;
if(error.tag == "uuid_conflict") {
// uuid conflicts can occur if a user attempts to import an old data archive with uuids form the old account into a new account
// uuid conflicts can occur if a user attempts to import an old data archive with uuids from the old account into a new account
this.modelManager.alternateUUIDForItem(item, handleNext);
}
++i;