Covered all the migration cases.
This commit is contained in:
parent
afe433d909
commit
cc45e91680
1 changed files with 19 additions and 40 deletions
|
|
@ -136,30 +136,29 @@ angular.module('copayApp.services')
|
||||||
* @param {getProfileCallback} cb
|
* @param {getProfileCallback} cb
|
||||||
*/
|
*/
|
||||||
function _migrateProfiles(oldProfile, secureProfile, cb) {
|
function _migrateProfiles(oldProfile, secureProfile, cb) {
|
||||||
|
var newProfile = oldProfile;
|
||||||
|
|
||||||
if (secureProfile) {
|
if (secureProfile) {
|
||||||
secureProfile.merge(oldProfile);
|
secureProfile.merge(oldProfile);
|
||||||
|
newProfile = secureProfile;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
root.storeNewProfile(newProfile, function(storeErr) {
|
||||||
root.storeNewProfile(secureProfile, function(err) {
|
if (storeErr) {
|
||||||
if (err) {
|
cb(storeErr, null);
|
||||||
cb(err, null);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
storage.remove('profile', function(removeErr){
|
||||||
|
if (removeErr) {
|
||||||
|
cb(removeErr, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.remove('profile', function(err){
|
cb(null, newProfile);
|
||||||
if (err) {
|
|
||||||
cb(err, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cb(null, securePofile);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -178,25 +177,23 @@ angular.module('copayApp.services')
|
||||||
if (secureStr) {
|
if (secureStr) {
|
||||||
try {
|
try {
|
||||||
secureProfile = Profile.fromString(secureStr);
|
secureProfile = Profile.fromString(secureStr);
|
||||||
$log.error('profile: ' + JSON.stringify(secureProfile));
|
$log.debug('profile: ' + JSON.stringify(secureProfile));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$log.error(e);
|
$log.error(e);
|
||||||
return cb(e, null);
|
return cb(e, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore insecure stuff for now
|
storage.get('profile', function(getErr, getStr) {
|
||||||
return cb(null, secureProfile);
|
|
||||||
|
|
||||||
storage.get('profile', function(getErr, str) {
|
|
||||||
if (getErr) {
|
if (getErr) {
|
||||||
return cb(getErr);
|
return cb(getErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!str) {
|
if (!getStr) {
|
||||||
if (secureProfile) {
|
if (secureProfile) {
|
||||||
return cb(null, secureProfile);
|
return cb(null, secureProfile);
|
||||||
} else {
|
} else {
|
||||||
|
// No profiles found. No errors either.
|
||||||
return cb(null, null);
|
return cb(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +209,6 @@ angular.module('copayApp.services')
|
||||||
return(err, null);
|
return(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we have to do a migration
|
|
||||||
_migrateProfiles(oldProfile, secureProfile, cb);
|
_migrateProfiles(oldProfile, secureProfile, cb);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -220,23 +216,6 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
if (err || !str)
|
|
||||||
return cb(err);
|
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
root.setFeedbackInfo = function(feedbackValues, cb) {
|
root.setFeedbackInfo = function(feedbackValues, cb) {
|
||||||
storage.set('feedback', feedbackValues, cb);
|
storage.set('feedback', feedbackValues, cb);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue