diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 75d34fe1a..1d7d03738 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -131,20 +131,31 @@ angular.module('copayApp.services') /** * - * @param {Profile} oldProfile + * @param {Profile} oldProfile * @param {Profile} secureProfile - may be falsy if no secure profile found. * @param {getProfileCallback} cb */ function _migrateProfiles(oldProfile, secureProfile, cb) { if (secureProfile) { + secureProfile.merge(oldProfile); } else { - root.storeNewProfile(oldProfile, function(err) { + root.storeNewProfile(secureProfile, function(err) { if (err) { cb(err, null); return; } + storage.remove('profile', function(err){ + if (err) { + cb(err, null); + return; + } + + cb(null, securePofile); + + }); + return; }); } @@ -161,18 +172,22 @@ angular.module('copayApp.services') var oldProfile; if (secureErr) { - return cb(secureErr); + return cb(secureErr, null); } if (secureStr) { try { secureProfile = Profile.fromString(secureStr); + $log.error('profile: ' + JSON.stringify(secureProfile)); } catch (e) { - var profileError = new Error('Could not read secure profile.'); - return cb(profileError, null); + $log.error(e); + return cb(e, null); } } + // Ignore insecure stuff for now + return cb(null, secureProfile); + storage.get('profile', function(getErr, str) { if (getErr) { return cb(getErr);