Starting to migrate profile storage.
This commit is contained in:
parent
adf7115c9c
commit
afe433d909
1 changed files with 20 additions and 5 deletions
|
|
@ -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 {Profile} secureProfile - may be falsy if no secure profile found.
|
||||||
* @param {getProfileCallback} cb
|
* @param {getProfileCallback} cb
|
||||||
*/
|
*/
|
||||||
function _migrateProfiles(oldProfile, secureProfile, cb) {
|
function _migrateProfiles(oldProfile, secureProfile, cb) {
|
||||||
if (secureProfile) {
|
if (secureProfile) {
|
||||||
|
secureProfile.merge(oldProfile);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
root.storeNewProfile(oldProfile, function(err) {
|
root.storeNewProfile(secureProfile, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
cb(err, null);
|
cb(err, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storage.remove('profile', function(err){
|
||||||
|
if (err) {
|
||||||
|
cb(err, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cb(null, securePofile);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -161,18 +172,22 @@ angular.module('copayApp.services')
|
||||||
var oldProfile;
|
var oldProfile;
|
||||||
|
|
||||||
if (secureErr) {
|
if (secureErr) {
|
||||||
return cb(secureErr);
|
return cb(secureErr, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secureStr) {
|
if (secureStr) {
|
||||||
try {
|
try {
|
||||||
secureProfile = Profile.fromString(secureStr);
|
secureProfile = Profile.fromString(secureStr);
|
||||||
|
$log.error('profile: ' + JSON.stringify(secureProfile));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var profileError = new Error('Could not read secure profile.');
|
$log.error(e);
|
||||||
return cb(profileError, null);
|
return cb(e, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore insecure stuff for now
|
||||||
|
return cb(null, secureProfile);
|
||||||
|
|
||||||
storage.get('profile', function(getErr, str) {
|
storage.get('profile', function(getErr, str) {
|
||||||
if (getErr) {
|
if (getErr) {
|
||||||
return cb(getErr);
|
return cb(getErr);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue