From 9224d40a6554c70b0c500ca4e80031fb89e867e6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Mon, 2 Jul 2018 14:06:36 +0900 Subject: [PATCH 1/4] Remove secure storage feature, postpone --- app-template/config-template.xml | 2 -- src/js/services/storageService.js | 55 +++++-------------------------- 2 files changed, 8 insertions(+), 49 deletions(-) diff --git a/app-template/config-template.xml b/app-template/config-template.xml index ed4b192ba..52a3f8860 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -73,8 +73,6 @@ - - diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index a2d85950b..bde3215a2 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.services') - .factory('storageService', function(appConfigService, logHeader, fileStorageService, localStorageService, sjcl, $log, lodash, platformInfo, secureStorageService, $timeout) { + .factory('storageService', function(appConfigService, logHeader, fileStorageService, localStorageService, sjcl, $log, lodash, platformInfo, $timeout) { var root = {}; var storage; @@ -121,11 +121,7 @@ angular.module('copayApp.services') root.storeProfile = function(profile, cb) { var profileString = profile.toObj(); - if (platformInfo.isNW) { - storage.set('profile', profileString, cb); - } else { - secureStorageService.set('profile', profileString, cb); - } + storage.set('profile', profileString, cb); }; /** @@ -205,48 +201,13 @@ angular.module('copayApp.services') * @param {getProfileCallback} cb */ root.getProfile = function(cb) { - if (platformInfo.isNW) { - storage.get('profile', function(getErr, getStr) { - _onOldProfileRetrieved(getErr, getStr, cb); - }); - return - } - - secureStorageService.get('profile', function(secureErr, secureStr) { - var secureProfile; - var oldProfile; - - if (secureErr) { - return cb(secureErr, null); + storage.get('profile', function(getErr, getStr) { + if (getErr) { + cb(getErr, null); + } else { + profile = Profile.fromString(getStr); + cb(null, profile); } - - if (secureStr) { - try { - secureProfile = Profile.fromString(secureStr); - $log.debug('profile: ' + JSON.stringify(secureProfile)); - } catch (e) { - $log.error(e); - return cb(e, null); - } - } - - storage.get('profile', function(getErr, getStr) { - _onOldProfileRetrieved(getErr, getStr, function(oldErr, oldProfile){ - if (oldErr) { - return cb(oldErr, null); - } - - if (!oldProfile) { - if (secureProfile) { - return cb(null, secureProfile); - } else { - // No profiles found. No errors either. - return cb(null, null); - } - } - _migrateProfiles(oldProfile, secureProfile, cb); - }); - }); }); }; From eaaafbba6fb8cb6c441ad94c2a9fd60e5ed813e2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Mon, 2 Jul 2018 14:34:33 +0900 Subject: [PATCH 2/4] Mistake case where there is not profile --- src/js/services/storageService.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index bde3215a2..85d2e58cf 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -203,10 +203,14 @@ angular.module('copayApp.services') root.getProfile = function(cb) { storage.get('profile', function(getErr, getStr) { if (getErr) { - cb(getErr, null); + return cb(getErr, null); } else { - profile = Profile.fromString(getStr); - cb(null, profile); + if (!getStr) { + return cb(null, null); + } else { + profile = Profile.fromString(getStr); + return cb(null, profile); + } } }); }; From 867063fc8f77e7669c837fdebab818c1e8ce2f15 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Mon, 2 Jul 2018 17:57:51 +1200 Subject: [PATCH 3/4] Handle first launch. --- src/js/services/storageService.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index bde3215a2..44081a81f 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -204,10 +204,16 @@ angular.module('copayApp.services') storage.get('profile', function(getErr, getStr) { if (getErr) { cb(getErr, null); - } else { - profile = Profile.fromString(getStr); - cb(null, profile); + return; } + + if (!getStr) { + cb(null, null); + return; + } + + profile = Profile.fromString(getStr); + cb(null, profile); }); }; From 2422efdb462e1c9b252e2c9e3076810f16751539 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Mon, 2 Jul 2018 18:02:32 +1200 Subject: [PATCH 4/4] Bugfix for last commit. --- src/js/services/storageService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 44081a81f..10f0cdd76 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -212,7 +212,7 @@ angular.module('copayApp.services') return; } - profile = Profile.fromString(getStr); + var profile = Profile.fromString(getStr); cb(null, profile); }); };