Updates to password wizard

This commit is contained in:
Mo Bitar
2018-05-24 11:27:14 -05:00
parent f9d5323336
commit 0dbeff78a6
11 changed files with 86 additions and 43 deletions

View File

@@ -25,6 +25,11 @@ angular.module('app')
.controller('FooterCtrl', function ($rootScope, authManager, modelManager, $timeout, dbManager,
syncManager, storageManager, passcodeManager, componentManager, singletonManager, nativeExtManager) {
this.securityUpdateAvailable = authManager.securityUpdateAvailable;
this.openSecurityUpdate = function() {
authManager.presentPasswordWizard("upgrade-security");
}
$rootScope.$on("reload-ext-data", () => {
if(this.reloadInProgress) { return; }
this.reloadInProgress = true;

View File

@@ -16,6 +16,7 @@ class AccountMenu {
$scope.formData = {mergeLocal: true, url: syncManager.serverURL, ephemeral: false};
$scope.user = authManager.user;
$scope.server = syncManager.serverURL;
$scope.securityUpdateAvailable = authManager.securityUpdateAvailable;
$scope.close = function() {
$timeout(() => {
@@ -152,10 +153,10 @@ class AccountMenu {
}
$scope.openPasswordWizard = function(type) {
var scope = $rootScope.$new(true);
scope.type = type;
var el = $compile( "<password-wizard type='type'></password-wizard>" )(scope);
angular.element(document.body).append(el);
// Close the account menu
$scope.close();
authManager.presentPasswordWizard(type);
}
// Allows indexeddb unencrypted logs to be deleted

View File

@@ -122,14 +122,14 @@ class PasswordWizard {
$scope.resyncData((syncSuccess) => {
$scope.formData.statusError = !syncSuccess;
$scope.formData.processing = syncSuccess;
$scope.formData.processing = !syncSuccess;
if(syncSuccess) {
$scope.lockContinue = false;
if($scope.changePassword) {
$scope.formData.status = "Successfully changed password and re-encrypted all items. Press Continue to proceed.";
$scope.formData.status = "Successfully changed password and synced all items.";
} else if($scope.securityUpdate) {
$scope.formData.status = "Successfully performed security update and re-encrypted all items. Press Continue to proceed.";
$scope.formData.status = "Successfully performed security update and synced all items.";
}
} else {
$scope.formData.status = FailedSyncMessage;
@@ -203,9 +203,9 @@ class PasswordWizard {
let currentServerPw = this.currentServerPw;
SFJS.crypto.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword).then((results) => {
let newKeys = results.newKeys;
let newAuthParams = results.newAuthParams;
let newKeys = results.keys;
let newAuthParams = results.authParams;
// 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((response) => {
authManager.changePassword(currentServerPw, newKeys, newAuthParams, (response) => {

View File

@@ -7,11 +7,11 @@ angular.module('app')
return domain;
}
this.$get = function($rootScope, $timeout, httpManager, modelManager, dbManager, storageManager, singletonManager) {
return new AuthManager($rootScope, $timeout, httpManager, modelManager, dbManager, storageManager, singletonManager);
this.$get = function($rootScope, $timeout, httpManager, modelManager, dbManager, storageManager, singletonManager, $compile) {
return new AuthManager($rootScope, $timeout, httpManager, modelManager, dbManager, storageManager, singletonManager, $compile);
}
function AuthManager($rootScope, $timeout, httpManager, modelManager, dbManager, storageManager, singletonManager) {
function AuthManager($rootScope, $timeout, httpManager, modelManager, dbManager, storageManager, singletonManager, $compile) {
this.loadInitialData = function() {
var userData = storageManager.getItem("user");
@@ -238,7 +238,7 @@ angular.module('app')
let newServerPw = newKeys.pw;
var requestUrl = storageManager.getItem("server") + "/auth/change_pw";
var params = _.merge({new_password: newServerPw}, newAuthParams);
var params = _.merge({new_password: newServerPw, current_password: current_server_pw}, newAuthParams);
httpManager.postAbsolute(requestUrl, params, (response) => {
this.handleAuthResponse(response, email, null, newAuthParams, newKeys);
@@ -275,10 +275,14 @@ angular.module('app')
}
let latest = SFJS.version();
this.securityUpdateAvailable = this.protocolVersion() !== latest;
}
if(this.protocolVersion() !== latest) {
// Prompt user to perform security update
}
this.presentPasswordWizard = function(type) {
var scope = $rootScope.$new(true);
scope.type = type;
var el = $compile( "<password-wizard type='type'></password-wizard>" )(scope);
angular.element(document.body).append(el);
}
this.staticifyObject = function(object) {