mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #3602 from cmgustavo/ref/disclaimer-flag
Ref bootstrapping (disclaimer)
This commit is contained in:
commit
74d7b24d02
|
@ -18,7 +18,7 @@
|
|||
ng-controller="indexController as index"
|
||||
ng-swipe-disable-mouse
|
||||
ng-swipe-left="index.closeMenu()"
|
||||
ng-swipe-right="index.agreeDisclaimer() ? index.openMenu() : null">
|
||||
ng-swipe-right="index.openMenu()">
|
||||
|
||||
<div class="off-canvas-wrap" id="off-canvas-wrap">
|
||||
<div class="inner-wrap">
|
||||
|
|
|
@ -1,56 +1,54 @@
|
|||
<div class="splash content text-center"
|
||||
ng-controller="disclaimerController">
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns">
|
||||
<img src="img/icon-splash.png" alt="icon" width="100%">
|
||||
ng-controller="disclaimerController as disclaimer" ng-init="disclaimer.init()">
|
||||
<div class="row">
|
||||
<div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns">
|
||||
<img src="img/icon-splash.png" alt="icon" width="100%">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-centered small-centered large-centered columns">
|
||||
<span class="text-bold size-16 text-white" translate>WELCOME TO COPAY</span>
|
||||
<p class="text-gray size-14 m0 text-light" translate>A multisignature bitcoin wallet</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-centered small-centered large-centered columns">
|
||||
<span class="text-bold size-16 text-white" translate>WELCOME TO COPAY</span>
|
||||
<p class="text-gray size-14 m0 text-light" translate>A multisignature bitcoin wallet</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="scrollArea">
|
||||
<p class="enable_text_select m0">
|
||||
<div class="size-16 text-gray" translate>Terms of Use</div>
|
||||
<div ng-include="'views/includes/terms.html'"></div>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<p ng-show="lang != 'en'">
|
||||
<a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="scrollArea">
|
||||
<p class="enable_text_select m0">
|
||||
<div class="size-16 text-gray" translate>Terms of Use</div>
|
||||
<div ng-include="'views/includes/terms.html'"></div>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray columns" translate>I affirm that I have read, understood, and agree with these terms.</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center size-12 text-warning" ng-show="error">
|
||||
{{(error)|translate}}. <span translate>Retrying...</span>
|
||||
</div>
|
||||
<div class="onGoingProcess" ng-show="creatingProfile">
|
||||
<div class="onGoingProcess-content" ng-style="{'background-color':'#222'}">
|
||||
<div class="spinner">
|
||||
<div class="rect1"></div>
|
||||
<div class="rect2"></div>
|
||||
<div class="rect3"></div>
|
||||
<div class="rect4"></div>
|
||||
<div class="rect5"></div>
|
||||
</div>
|
||||
<span translate>Creating Profile...</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p ng-show="disclaimer.lang != 'en'">
|
||||
<a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray columns" translate>I affirm that I have read, understood, and agree with these terms.</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="text-center size-12 text-warning" ng-show="error">
|
||||
{{(error)|translate}}. <span translate>Retrying...</span>
|
||||
</div>
|
||||
<div class="start-button columns">
|
||||
<button ng-disabled="creatingProfile" ng-click="goHome()" class="button black expand round size-12 text-spacing" translate>
|
||||
I AGREE. GET STARTED
|
||||
</button>
|
||||
<div class="onGoingProcess" ng-show="creatingProfile">
|
||||
<div class="onGoingProcess-content" ng-style="{'background-color':'#222'}">
|
||||
<div class="spinner">
|
||||
<div class="rect1"></div>
|
||||
<div class="rect2"></div>
|
||||
<div class="rect3"></div>
|
||||
<div class="rect4"></div>
|
||||
<div class="rect5"></div>
|
||||
</div>
|
||||
<span translate>Creating Profile...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="start-button columns">
|
||||
<button ng-disabled="creatingProfile" ng-click="index.acceptDisclaimer()" class="button black expand round size-12 text-spacing" translate>
|
||||
I AGREE. GET STARTED
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,18 +3,6 @@
|
|||
angular.module('copayApp.controllers').controller('disclaimerController',
|
||||
function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) {
|
||||
self = this;
|
||||
$scope.lang = uxLanguage.currentLanguage;
|
||||
|
||||
$scope.goHome = function() {
|
||||
$scope.error = "";
|
||||
profileService.storeDisclaimer(function(err) {
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
$log.warn(err);
|
||||
$scope.$apply();
|
||||
} else go.walletHome();
|
||||
});
|
||||
};
|
||||
|
||||
var create = function() {
|
||||
$scope.creatingProfile = true;
|
||||
|
@ -35,13 +23,16 @@ angular.module('copayApp.controllers').controller('disclaimerController',
|
|||
});
|
||||
};
|
||||
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (!profile) create();
|
||||
else $scope.creatingProfile = false;
|
||||
this.init = function() {
|
||||
self.lang = uxLanguage.currentLanguage;
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (!profile) create();
|
||||
else $scope.creatingProfile = false;
|
||||
|
||||
//compatible
|
||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
||||
if (val) go.walletHome();
|
||||
//compatible
|
||||
profileService.isDisclaimerAccepted(function(val) {
|
||||
if (val) go.walletHome();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -125,7 +125,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
self.initGlidera();
|
||||
|
||||
self.setCustomBWSFlag();
|
||||
self.setCustomBWSFlag();
|
||||
if (fc.isPrivKeyExternal()) {
|
||||
self.needsBackup = false;
|
||||
self.openWallet();
|
||||
|
@ -141,14 +141,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
};
|
||||
|
||||
self.agreeDisclaimer = function() {
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (profile && profile.agreeDisclaimer)
|
||||
return profile.agreeDisclaimer;
|
||||
return null;
|
||||
});
|
||||
};
|
||||
|
||||
self.setCustomBWSFlag = function() {
|
||||
var defaults = configService.getDefaults();
|
||||
var config = configService.getSync();
|
||||
|
@ -156,6 +148,28 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url);
|
||||
};
|
||||
|
||||
self.acceptDisclaimer = function() {
|
||||
var profile = profileService.profile;
|
||||
if (profile) profile.disclaimerAccepted = true;
|
||||
self.disclaimerAccepted = true;
|
||||
profileService.setDisclaimerAccepted(function(err) {
|
||||
if (err) $log.error(err);
|
||||
go.walletHome();
|
||||
});
|
||||
};
|
||||
|
||||
self.isDisclaimerAccepted = function() {
|
||||
if (self.disclaimerAccepted == true) {
|
||||
go.walletHome();
|
||||
return;
|
||||
}
|
||||
profileService.isDisclaimerAccepted(function(v) {
|
||||
if (v) {
|
||||
self.acceptDisclaimer();
|
||||
} else go.path('disclaimer');
|
||||
});
|
||||
};
|
||||
|
||||
self.setTab = function(tab, reset, tries, switchState) {
|
||||
tries = tries || 0;
|
||||
|
||||
|
@ -980,6 +994,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
};
|
||||
|
||||
self.openMenu = function() {
|
||||
if (!self.disclaimerAccepted) return;
|
||||
go.swipe(true);
|
||||
};
|
||||
|
||||
|
@ -1168,10 +1183,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/NewFocusedWallet', function() {
|
||||
self.setUxLanguage();
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/LanguageSettingUpdated', function() {
|
||||
self.setUxLanguage();
|
||||
self.updateRemotePreferences({
|
||||
|
@ -1229,6 +1240,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
$rootScope.$on('Local/Resume', function(event) {
|
||||
$log.debug('### Resume event');
|
||||
self.isDisclaimerAccepted();
|
||||
self.debouncedUpdate();
|
||||
});
|
||||
|
||||
|
@ -1348,24 +1360,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
|
||||
$rootScope.$on('Local/NewFocusedWallet', function() {
|
||||
self.setUxLanguage();
|
||||
self.setFocusedWallet();
|
||||
self.updateTxHistory();
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (profile && profile.agreeDisclaimer) go.walletHome();
|
||||
|
||||
//compatible
|
||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
||||
if (val) go.walletHome();
|
||||
storageService.getCleanAndScanAddresses(function(err, walletId) {
|
||||
if (walletId && profileService.walletClients[walletId]) {
|
||||
$log.debug('Clear last address cache and Scan ', walletId);
|
||||
addressService.expireAddress(walletId, function(err) {
|
||||
self.startScan(walletId);
|
||||
});
|
||||
storageService.removeCleanAndScanAddresses(function() {});
|
||||
}
|
||||
self.isDisclaimerAccepted();
|
||||
storageService.getCleanAndScanAddresses(function(err, walletId) {
|
||||
if (walletId && profileService.walletClients[walletId]) {
|
||||
$log.debug('Clear last address cache and Scan ', walletId);
|
||||
addressService.expireAddress(walletId, function(err) {
|
||||
self.startScan(walletId);
|
||||
});
|
||||
});
|
||||
storageService.removeCleanAndScanAddresses(function() {});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ Profile.create = function(opts) {
|
|||
var x = new Profile();
|
||||
x.createdOn = Date.now();
|
||||
x.credentials = opts.credentials || [];
|
||||
x.agreeDisclaimer = false;
|
||||
x.disclaimerAccepted = false;
|
||||
return x;
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,7 @@ Profile.fromObj = function(obj) {
|
|||
|
||||
x.createdOn = obj.createdOn;
|
||||
x.credentials = obj.credentials;
|
||||
x.agreeDisclaimer = obj.agreeDisclaimer;
|
||||
x.disclaimerAccepted = obj.disclaimerAccepted;
|
||||
|
||||
if (x.credentials[0] && typeof x.credentials[0] != 'object')
|
||||
throw ("credentials should be an object");
|
||||
|
|
|
@ -118,7 +118,7 @@ angular.module('copayApp.services')
|
|||
|
||||
root.bindProfile = function(profile, cb) {
|
||||
root.profile = profile;
|
||||
|
||||
|
||||
configService.get(function(err) {
|
||||
$log.debug('Preferences read');
|
||||
if (err) return cb(err);
|
||||
|
@ -127,13 +127,21 @@ angular.module('copayApp.services')
|
|||
if (err) return cb(err);
|
||||
root._setFocus(focusedWalletId, function() {
|
||||
$rootScope.$emit('Local/ProfileBound');
|
||||
return cb();
|
||||
root.isDisclaimerAccepted(function(val) {
|
||||
if (!val) {
|
||||
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
||||
}
|
||||
else {
|
||||
return cb();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
root.loadAndBindProfile = function(cb) {
|
||||
root.loadAndBindProfile = function(cb) {
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (err) {
|
||||
$rootScope.$emit('Local/DeviceError', err);
|
||||
|
@ -150,13 +158,8 @@ 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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -518,14 +521,38 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
root.storeDisclaimer = function(cb) {
|
||||
root.setDisclaimerAccepted = function(cb) {
|
||||
storageService.getProfile(function(err, profile) {
|
||||
profile.agreeDisclaimer = true;
|
||||
storageService.storeProfile(profile, function() {
|
||||
profile.disclaimerAccepted = true;
|
||||
storageService.storeProfile(profile, function(err) {
|
||||
return cb(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
root.isDisclaimerAccepted = function(cb) {
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (profile && profile.disclaimerAccepted)
|
||||
return cb(true);
|
||||
else if (profile && !profile.disclaimerAccepted) {
|
||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
||||
if (val) {
|
||||
profile.disclaimerAccepted = true;
|
||||
storageService.storeProfile(profile, 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();
|
||||
|
|
Loading…
Reference in New Issue