Merge pull request #5896 from JDonadio/bug/config-lock
Fix lock options by default
This commit is contained in:
commit
79653c5945
8 changed files with 96 additions and 72 deletions
|
|
@ -1,21 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('lockController', function($state, $scope, $timeout, $log, configService, popupService, gettextCatalog, appConfigService, fingerprintService, profileService, lodash) {
|
||||
angular.module('copayApp.controllers').controller('lockSetupController', function($state, $scope, $timeout, $log, configService, popupService, gettextCatalog, appConfigService, fingerprintService, profileService, lodash) {
|
||||
|
||||
function init() {
|
||||
var config = configService.getSync();
|
||||
$scope.locking = config.lock.method != 'pin';
|
||||
|
||||
$scope.options = [
|
||||
{
|
||||
method: 'none',
|
||||
method: null,
|
||||
label: gettextCatalog.getString('Disabled'),
|
||||
value: config.lock.method == '',
|
||||
},
|
||||
{
|
||||
method: 'pin',
|
||||
label: gettextCatalog.getString('Enable PIN'),
|
||||
value: config.lock.method == 'pin',
|
||||
label: gettextCatalog.getString('Lock by PIN'),
|
||||
needsBackup: null,
|
||||
},
|
||||
];
|
||||
|
|
@ -23,13 +18,17 @@ angular.module('copayApp.controllers').controller('lockController', function($st
|
|||
if (fingerprintService.isAvailable()) {
|
||||
$scope.options.push({
|
||||
method: 'fingerprint',
|
||||
label: gettextCatalog.getString('Enable Fingerprint'),
|
||||
value: config.lock.method == 'fingerprint',
|
||||
label: gettextCatalog.getString('Lock by Fingerprint'),
|
||||
needsBackup: null,
|
||||
});
|
||||
}
|
||||
|
||||
$scope.currentOption = lodash.find($scope.options, 'value');
|
||||
var config = configService.getSync();
|
||||
var method = config.lock && config.lock.method;
|
||||
if (!method) $scope.currentOption = $scope.options[0];
|
||||
else $scope.currentOption = lodash.find($scope.options, {
|
||||
'method': method
|
||||
});
|
||||
processWallets();
|
||||
};
|
||||
|
||||
|
|
@ -70,21 +69,24 @@ angular.module('copayApp.controllers').controller('lockController', function($st
|
|||
});
|
||||
};
|
||||
|
||||
$scope.select = function(method) {
|
||||
if (method == 'none')
|
||||
$scope.select = function(selectedMethod) {
|
||||
var config = configService.getSync();
|
||||
var savedMethod = config.lock && config.lock.method;
|
||||
|
||||
if (!selectedMethod)
|
||||
saveConfig();
|
||||
else if (method == 'fingerprint') {
|
||||
var config = configService.getSync();
|
||||
if (config.lock.method == 'pin') {
|
||||
else if (selectedMethod == 'fingerprint') {
|
||||
if (savedMethod == 'pin') {
|
||||
askForDisablePin(function(disablePin) {
|
||||
if (disablePin) saveConfig('fingerprint');
|
||||
else init();
|
||||
});
|
||||
} else saveConfig('fingerprint');
|
||||
} else if (method == 'pin') {
|
||||
$state.transitionTo('tabs.lock.pin', {
|
||||
} else if (selectedMethod == 'pin') {
|
||||
if (savedMethod == 'pin') return;
|
||||
$state.transitionTo('tabs.pin', {
|
||||
fromSettings: true,
|
||||
locking: $scope.locking
|
||||
locking: savedMethod == 'pin' ? false : true
|
||||
});
|
||||
}
|
||||
$timeout(function() {
|
||||
|
|
@ -93,7 +95,7 @@ angular.module('copayApp.controllers').controller('lockController', function($st
|
|||
};
|
||||
|
||||
function askForDisablePin(cb) {
|
||||
var message = gettextCatalog.getString('{{appName}} is protected by Pin. Are you sure you want to disable it?', {
|
||||
var message = gettextCatalog.getString('{{appName}} startup is locked by PIN. Are you sure you want to disable it?', {
|
||||
appName: appConfigService.nameCase
|
||||
});
|
||||
var okText = gettextCatalog.getString('Continue');
|
||||
|
|
@ -107,8 +109,8 @@ angular.module('copayApp.controllers').controller('lockController', function($st
|
|||
function saveConfig(method) {
|
||||
var opts = {
|
||||
lock: {
|
||||
method: method || '',
|
||||
value: '',
|
||||
method: method || null,
|
||||
value: null,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -15,6 +15,7 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
|||
|
||||
$scope.$on("$ionicView.enter", function(event) {
|
||||
configService.whenAvailable(function(config) {
|
||||
if (!config.lock) return;
|
||||
$scope.bannedUntil = config.lock.bannedUntil || null;
|
||||
if ($scope.bannedUntil) {
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
|
|
@ -156,12 +157,13 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
|||
|
||||
function saveSettings(method, value) {
|
||||
var config = configService.getSync();
|
||||
var attempts = config.lock && config.lock.attempts ? config.lock.attempts : 0;
|
||||
var opts = {
|
||||
lock: {
|
||||
method: method || '',
|
||||
value: value || '',
|
||||
method: method || null,
|
||||
value: value || null,
|
||||
bannedUntil: null,
|
||||
attempts: config.lock.attempts + 1,
|
||||
attempts: attempts + 1,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -173,7 +175,12 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
|||
|
||||
$scope.close = function(delay) {
|
||||
$timeout(function() {
|
||||
$ionicHistory.viewHistory().backView ? $ionicHistory.goBack() : $state.go('tabs.home');
|
||||
var shouldReturn = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName != 'starting';
|
||||
|
||||
if (shouldReturn)
|
||||
$ionicHistory.goBack()
|
||||
else
|
||||
$state.go('tabs.home');
|
||||
}, delay || 1);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
|
|||
$scope.isDevel = platformInfo.isDevel;
|
||||
$scope.appName = appConfigService.nameCase;
|
||||
configService.whenAvailable(function(config) {
|
||||
$scope.locked = config.lock && config.lock.method != '' ? true : false;
|
||||
$scope.method = config.lock && config.lock.method != '' ? config.lock.method.charAt(0).toUpperCase() + config.lock.method.slice(1) : gettextCatalog.getString('Disabled');
|
||||
$scope.locked = config.lock && config.lock.method;
|
||||
$scope.method = $scope.locked ? config.lock.method.charAt(0).toUpperCase() + config.lock.method.slice(1) : gettextCatalog.getString('Disabled');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue