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.lang = uxLanguage.currentLanguage;
|
||||||
|
|
||||||
$scope.goHome = function() {
|
$scope.goHome = function() {
|
||||||
go.walletHome();
|
storageService.setCopayDisclaimerFlag(function(err) {
|
||||||
|
go.walletHome();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var create = function() {
|
var create = function() {
|
||||||
|
|
@ -15,16 +17,20 @@ angular.module('copayApp.controllers').controller('disclaimerController',
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
||||||
if (err == 'EEXISTS')
|
if (err == 'EEXISTS') {
|
||||||
return go.walletHome();
|
storageService.getCopayDisclaimerFlag(function(val) {
|
||||||
|
if (val) return go.walletHome();
|
||||||
$log.warn(err);
|
$scope.creatingProfile = false;
|
||||||
$scope.error = err;
|
});
|
||||||
$scope.$apply();
|
} else {
|
||||||
$timeout(function() {
|
$log.warn(err);
|
||||||
$log.warn('Retrying to create profile......');
|
$scope.error = err;
|
||||||
create();
|
$scope.$apply();
|
||||||
}, 3000);
|
$timeout(function() {
|
||||||
|
$log.warn('Retrying to create profile......');
|
||||||
|
create();
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$scope.error = "";
|
$scope.error = "";
|
||||||
$scope.creatingProfile = false;
|
$scope.creatingProfile = false;
|
||||||
|
|
|
||||||
|
|
@ -263,43 +263,39 @@ angular
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.state('preferencesGlidera', {
|
||||||
.state('preferencesGlidera', {
|
url: '/preferencesGlidera',
|
||||||
url: '/preferencesGlidera',
|
walletShouldBeComplete: true,
|
||||||
walletShouldBeComplete: true,
|
needProfile: true,
|
||||||
needProfile: true,
|
views: {
|
||||||
views: {
|
'main': {
|
||||||
'main': {
|
templateUrl: 'views/preferencesGlidera.html'
|
||||||
templateUrl: 'views/preferencesGlidera.html'
|
},
|
||||||
},
|
}
|
||||||
}
|
})
|
||||||
})
|
.state('preferencesAdvanced', {
|
||||||
|
url: '/preferencesAdvanced',
|
||||||
.state('preferencesAdvanced', {
|
templateUrl: 'views/preferencesAdvanced.html',
|
||||||
url: '/preferencesAdvanced',
|
walletShouldBeComplete: true,
|
||||||
templateUrl: 'views/preferencesAdvanced.html',
|
needProfile: true,
|
||||||
walletShouldBeComplete: true,
|
views: {
|
||||||
needProfile: true,
|
'main': {
|
||||||
views: {
|
templateUrl: 'views/preferencesAdvanced.html'
|
||||||
'main': {
|
},
|
||||||
templateUrl: 'views/preferencesAdvanced.html'
|
}
|
||||||
},
|
})
|
||||||
}
|
.state('preferencesColor', {
|
||||||
})
|
url: '/preferencesColor',
|
||||||
|
templateUrl: 'views/preferencesColor.html',
|
||||||
.state('preferencesColor', {
|
walletShouldBeComplete: true,
|
||||||
url: '/preferencesColor',
|
needProfile: true,
|
||||||
templateUrl: 'views/preferencesColor.html',
|
views: {
|
||||||
walletShouldBeComplete: true,
|
'main': {
|
||||||
needProfile: true,
|
templateUrl: 'views/preferencesColor.html'
|
||||||
views: {
|
},
|
||||||
'main': {
|
}
|
||||||
templateUrl: 'views/preferencesColor.html'
|
})
|
||||||
},
|
.state('preferencesAltCurrency', {
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
.state('preferencesAltCurrency', {
|
|
||||||
url: '/preferencesAltCurrency',
|
url: '/preferencesAltCurrency',
|
||||||
templateUrl: 'views/preferencesAltCurrency.html',
|
templateUrl: 'views/preferencesAltCurrency.html',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
|
|
@ -378,8 +374,7 @@ angular
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.state('about', {
|
||||||
.state('about', {
|
|
||||||
url: '/about',
|
url: '/about',
|
||||||
templateUrl: 'views/preferencesAbout.html',
|
templateUrl: 'views/preferencesAbout.html',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
|
|
@ -449,8 +444,7 @@ angular
|
||||||
templateUrl: 'views/warning.html',
|
templateUrl: 'views/warning.html',
|
||||||
needProfile: false
|
needProfile: false
|
||||||
})
|
})
|
||||||
|
.state('add', {
|
||||||
.state('add', {
|
|
||||||
url: '/add',
|
url: '/add',
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
|
|
@ -516,13 +510,15 @@ angular
|
||||||
|
|
||||||
// Give us time to open / create the profile
|
// Give us time to open / create the profile
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// Try to open local profile
|
// Try to open local profile
|
||||||
profileService.loadAndBindProfile(function(err) {
|
profileService.loadAndBindProfile(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.message && err.message.match('NOPROFILE')) {
|
if (err.message && err.message.match('NOPROFILE')) {
|
||||||
$log.debug('No profile... redirecting');
|
$log.debug('No profile... redirecting');
|
||||||
$state.transitionTo('disclaimer');
|
$state.transitionTo('disclaimer');
|
||||||
|
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
|
||||||
|
$log.debug('Display disclaimer... redirecting');
|
||||||
|
$state.transitionTo('disclaimer');
|
||||||
} else {
|
} else {
|
||||||
throw new Error(err); // TODO
|
throw new Error(err); // TODO
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -134,26 +134,31 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.loadAndBindProfile = function(cb) {
|
root.loadAndBindProfile = function(cb) {
|
||||||
storageService.getProfile(function(err, profile) {
|
storageService.getCopayDisclaimerFlag(function(err, val) {
|
||||||
if (err) {
|
if (!val) {
|
||||||
$rootScope.$emit('Local/DeviceError', err);
|
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
if (!profile) {
|
|
||||||
// Migration??
|
|
||||||
storageService.tryToMigrate(function(err, migratedProfile) {
|
|
||||||
if (err) return cb(err);
|
|
||||||
if (!migratedProfile)
|
|
||||||
return cb(new Error('NOPROFILE: No profile'));
|
|
||||||
|
|
||||||
profile = migratedProfile;
|
|
||||||
return root.bindProfile(profile, cb);
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
$log.debug('Profile read');
|
storageService.getProfile(function(err, profile) {
|
||||||
return root.bindProfile(profile, cb);
|
if (err) {
|
||||||
}
|
$rootScope.$emit('Local/DeviceError', err);
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
if (!profile) {
|
||||||
|
// Migration??
|
||||||
|
storageService.tryToMigrate(function(err, migratedProfile) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
if (!migratedProfile)
|
||||||
|
return cb(new Error('NOPROFILE: No profile'));
|
||||||
|
|
||||||
|
profile = migratedProfile;
|
||||||
|
return root.bindProfile(profile, cb);
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
$log.debug('Profile read');
|
||||||
|
return root.bindProfile(profile, cb);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -270,8 +275,8 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
// check if exist
|
// check if exist
|
||||||
if (lodash.find(root.profile.credentials, {
|
if (lodash.find(root.profile.credentials, {
|
||||||
'walletId': walletData.walletId
|
'walletId': walletData.walletId
|
||||||
})) {
|
})) {
|
||||||
return cb(gettext('Cannot join the same wallet more that once'));
|
return cb(gettext('Cannot join the same wallet more that once'));
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ angular.module('copayApp.services')
|
||||||
return storage.set('profile', text, function(err) {
|
return storage.set('profile', text, function(err) {
|
||||||
return cb(err, text);
|
return cb(err, text);
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
$log.warn('Decrypt error: ', e);
|
$log.warn('Decrypt error: ', e);
|
||||||
return cb('Could not decrypt storage: device ID mismatch');
|
return cb('Could not decrypt storage: device ID mismatch');
|
||||||
};
|
};
|
||||||
|
|
@ -199,6 +199,14 @@ angular.module('copayApp.services')
|
||||||
storage.remove('config', cb);
|
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) {
|
root.setRemotePrefsStoredFlag = function(cb) {
|
||||||
storage.set('remotePrefStored', true, cb);
|
storage.set('remotePrefStored', true, cb);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue