diff --git a/app-template/config-template.xml b/app-template/config-template.xml index 8031c8110..32440782c 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -72,6 +72,7 @@ + diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 3d1ecfeef..ea0a975c0 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -116,19 +116,60 @@ angular.module('copayApp.services') }; root.storeNewProfile = function(profile, cb) { - storage.create('profile', profile.toObj(), cb); + console.log('storeNewProfile() 6'); + + SecureStorage.set('profile', profile.toObj(), function success(){ cb(); }, function error(err){ cb(err); }); + + //storage.create('profile', profile.toObj(), cb); }; root.storeProfile = function(profile, cb) { - storage.set('profile', profile.toObj(), cb); + console.log('storeProfile() 6'); + SecureStorage.set('profile', profile.toObj(), function success(){ cb(); }, function error(err){ cb(err); }); + //storage.set('profile', profile.toObj(), cb); }; root.getProfile = function(cb) { - storage.get('profile', function(err, str) { - if (err || !str) - return cb(err); + console.log("getProfile() 6"); + + SecureStorage.get( + 'profile', + function success(str) { + $log.debug('get profile returned success.'); + decryptOnMobile(str, function(err, str) { + if (err) return cb(err); + var p, err; + try { + p = Profile.fromString(str); + } catch (e) { + $log.debug('Could not read profile:', e); + err = new Error('Could not read profile:' + p); + } + return cb(err, p); + }); + }, + function error(err) { + $log.debug('get profile returned error.'); + $log.debug('returning error.'); + // Callback requires no error and no profile for creation of new profiles + return cb(); + } + ); + + + + /* + storage.get('profile', function(err, str) { + $log.debug('get profile returned.'); + if (err || !str) { + $log.debug('get profile returned error: ' + err + ' with string: ' + str); + return cb(err); + } + + $log.debug('calling decrypt'); decryptOnMobile(str, function(err, str) { + $log.debug('decrypt returned.'); if (err) return cb(err); var p, err; try { @@ -140,8 +181,12 @@ angular.module('copayApp.services') return cb(err, p); }); }); + */ + + }; + // Is this ever used? root.deleteProfile = function(cb) { storage.remove('profile', cb); };