fix disclaimer
This commit is contained in:
parent
68f0157d47
commit
f23df02d0b
4 changed files with 89 additions and 74 deletions
|
|
@ -6,7 +6,9 @@ angular.module('copayApp.controllers').controller('disclaimerController',
|
|||
$scope.lang = uxLanguage.currentLanguage;
|
||||
|
||||
$scope.goHome = function() {
|
||||
storageService.setCopayDisclaimerFlag(function(err) {
|
||||
go.walletHome();
|
||||
});
|
||||
};
|
||||
|
||||
var create = function() {
|
||||
|
|
@ -15,9 +17,12 @@ angular.module('copayApp.controllers').controller('disclaimerController',
|
|||
|
||||
if (err) {
|
||||
|
||||
if (err == 'EEXISTS')
|
||||
return go.walletHome();
|
||||
|
||||
if (err == 'EEXISTS') {
|
||||
storageService.getCopayDisclaimerFlag(function(val) {
|
||||
if (val) return go.walletHome();
|
||||
$scope.creatingProfile = false;
|
||||
});
|
||||
} else {
|
||||
$log.warn(err);
|
||||
$scope.error = err;
|
||||
$scope.$apply();
|
||||
|
|
@ -25,6 +30,7 @@ angular.module('copayApp.controllers').controller('disclaimerController',
|
|||
$log.warn('Retrying to create profile......');
|
||||
create();
|
||||
}, 3000);
|
||||
}
|
||||
} else {
|
||||
$scope.error = "";
|
||||
$scope.creatingProfile = false;
|
||||
|
|
|
|||
|
|
@ -263,7 +263,6 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('preferencesGlidera', {
|
||||
url: '/preferencesGlidera',
|
||||
walletShouldBeComplete: true,
|
||||
|
|
@ -274,7 +273,6 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('preferencesAdvanced', {
|
||||
url: '/preferencesAdvanced',
|
||||
templateUrl: 'views/preferencesAdvanced.html',
|
||||
|
|
@ -286,7 +284,6 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('preferencesColor', {
|
||||
url: '/preferencesColor',
|
||||
templateUrl: 'views/preferencesColor.html',
|
||||
|
|
@ -298,7 +295,6 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('preferencesAltCurrency', {
|
||||
url: '/preferencesAltCurrency',
|
||||
templateUrl: 'views/preferencesAltCurrency.html',
|
||||
|
|
@ -378,7 +374,6 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('about', {
|
||||
url: '/about',
|
||||
templateUrl: 'views/preferencesAbout.html',
|
||||
|
|
@ -449,7 +444,6 @@ angular
|
|||
templateUrl: 'views/warning.html',
|
||||
needProfile: false
|
||||
})
|
||||
|
||||
.state('add', {
|
||||
url: '/add',
|
||||
needProfile: true,
|
||||
|
|
@ -516,13 +510,15 @@ angular
|
|||
|
||||
// Give us time to open / create the profile
|
||||
event.preventDefault();
|
||||
|
||||
// Try to open local profile
|
||||
profileService.loadAndBindProfile(function(err) {
|
||||
if (err) {
|
||||
if (err.message && err.message.match('NOPROFILE')) {
|
||||
$log.debug('No profile... redirecting');
|
||||
$state.transitionTo('disclaimer');
|
||||
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
|
||||
$log.debug('Display disclaimer... redirecting');
|
||||
$state.transitionTo('disclaimer');
|
||||
} else {
|
||||
throw new Error(err); // TODO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,10 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
root.loadAndBindProfile = function(cb) {
|
||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
||||
if (!val) {
|
||||
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
||||
} else {
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (err) {
|
||||
$rootScope.$emit('Local/DeviceError', err);
|
||||
|
|
@ -153,7 +157,8 @@ angular.module('copayApp.services')
|
|||
$log.debug('Profile read');
|
||||
return root.bindProfile(profile, cb);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ angular.module('copayApp.services')
|
|||
return storage.set('profile', text, function(err) {
|
||||
return cb(err, text);
|
||||
});
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
$log.warn('Decrypt error: ', e);
|
||||
return cb('Could not decrypt storage: device ID mismatch');
|
||||
};
|
||||
|
|
@ -199,6 +199,14 @@ angular.module('copayApp.services')
|
|||
storage.remove('config', cb);
|
||||
};
|
||||
|
||||
root.setCopayDisclaimerFlag = function(cb) {
|
||||
storage.set('agreeDisclaimer', true, cb);
|
||||
};
|
||||
|
||||
root.getCopayDisclaimerFlag = function(cb) {
|
||||
storage.get('agreeDisclaimer', cb);
|
||||
};
|
||||
|
||||
root.setRemotePrefsStoredFlag = function(cb) {
|
||||
storage.set('remotePrefStored', true, cb);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue