Ref bootstrapping (disclaimer)

This commit is contained in:
Gustavo Maximiliano Cortez 2015-12-04 18:45:35 -03:00
commit a28f9c0e7f
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 108 additions and 96 deletions

View file

@ -134,6 +134,11 @@ angular.module('copayApp.services')
};
root.loadAndBindProfile = function(cb) {
root.checkDisclaimer(function(val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
}
else {
storageService.getProfile(function(err, profile) {
if (err) {
$rootScope.$emit('Local/DeviceError', err);
@ -150,13 +155,10 @@ angular.module('copayApp.services')
return root.bindProfile(profile, cb);
})
} else {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (!profile.agreeDisclaimer) {
if (!val) return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
}
$log.debug('Profile read');
return root.bindProfile(profile, cb);
});
$log.debug('Profile read');
return root.bindProfile(profile, cb);
}
});
}
});
};
@ -521,11 +523,35 @@ angular.module('copayApp.services')
root.storeDisclaimer = function(cb) {
storageService.getProfile(function(err, profile) {
profile.agreeDisclaimer = true;
storageService.storeProfile(profile, function() {
storageService.storeProfile(profile, function(err) {
return cb(err);
});
});
}
};
root.checkDisclaimer = function(cb) {
if (root.profile && root.profile.agreeDisclaimer) return cb(true);
storageService.getProfile(function(err, profile) {
if (profile && profile.agreeDisclaimer)
return cb(true);
else if (profile && !profile.agreeDisclaimer) {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) {
root.storeDisclaimer(function(err) {
if (err) $log.error(err);
return cb(true);
});
}
else {
return cb();
}
});
}
else {
return cb();
}
});
};
root.importLegacyWallet = function(username, password, blob, cb) {
var walletClient = bwcService.getClient();