fix typo and constants
This commit is contained in:
parent
b040204841
commit
618ce14688
2 changed files with 20 additions and 23 deletions
|
|
@ -1,33 +1,30 @@
|
||||||
'use strict';
|
'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('lockController', function($state, $scope, $timeout, $log, configService, popupService, gettextCatalog, appConfigService, fingerprintService, profileService, lodash) {
|
||||||
var NONE = 'none';
|
|
||||||
var PIN = 'pin';
|
|
||||||
var FINGERPRINT = 'fingerprint';
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
$scope.locking = config.lock.method != PIN;
|
$scope.locking = config.lock.method != 'pin';
|
||||||
|
|
||||||
$scope.options = [
|
$scope.options = [
|
||||||
{
|
{
|
||||||
method: NONE,
|
method: 'none',
|
||||||
label: gettextCatalog.getString('Disabled'),
|
label: gettextCatalog.getString('Disabled'),
|
||||||
value: config.lock.method == '',
|
value: config.lock.method == '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
method: PIN,
|
method: 'pin',
|
||||||
label: gettextCatalog.getString('Enable PIN'),
|
label: gettextCatalog.getString('Enable PIN'),
|
||||||
value: config.lock.method == PIN,
|
value: config.lock.method == 'pin',
|
||||||
needsBackup: null,
|
needsBackup: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (fingerprintService.isAvailable()) {
|
if (fingerprintService.isAvailable()) {
|
||||||
$scope.options.push({
|
$scope.options.push({
|
||||||
method: FINGERPRINT,
|
method: 'fingerprint',
|
||||||
label: gettextCatalog.getString('Enable Fingerprint'),
|
label: gettextCatalog.getString('Enable Fingerprint'),
|
||||||
value: config.lock.method == FINGERPRINT,
|
value: config.lock.method == 'fingerprint',
|
||||||
needsBackup: null,
|
needsBackup: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -74,17 +71,17 @@ angular.module('copayApp.controllers').controller('lockController', function($st
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.select = function(method) {
|
$scope.select = function(method) {
|
||||||
if (method == NONE)
|
if (method == 'none')
|
||||||
saveConfig();
|
saveConfig();
|
||||||
else if (method == FINGERPRINT) {
|
else if (method == 'fingerprint') {
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
if (config.lock.method == PIN) {
|
if (config.lock.method == 'pin') {
|
||||||
askForDisablePin(function(disablePin) {
|
askForDisablePin(function(disablePin) {
|
||||||
if (disablePin) saveConfig(FINGERPRINT);
|
if (disablePin) saveConfig('fingerprint');
|
||||||
else init();
|
else init();
|
||||||
});
|
});
|
||||||
} else saveConfig(FINGERPRINT);
|
} else saveConfig('fingerprint');
|
||||||
} else if (method == PIN) {
|
} else if (method == 'pin') {
|
||||||
$state.transitionTo('tabs.lock.pin', {
|
$state.transitionTo('tabs.lock.pin', {
|
||||||
fromSettings: true,
|
fromSettings: true,
|
||||||
locking: $scope.locking
|
locking: $scope.locking
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('pinController', function($state, $interval, $stateParams, $ionicHistory, $timeout, $scope, $log, configService, appConfigService) {
|
angular.module('copayApp.controllers').controller('pinController', function($state, $interval, $stateParams, $ionicHistory, $timeout, $scope, $log, configService, appConfigService) {
|
||||||
var PIN = 'pin';
|
var ATTEMPT_LIMIT = 3;
|
||||||
var ATTEPMPTS_LIMIT = 3;
|
var ATTEMPT_LOCK_OUT_TIME = 5 * 60;
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event) {
|
$scope.$on("$ionicView.beforeEnter", function(event) {
|
||||||
$scope.currentPin = $scope.confirmPin = '';
|
$scope.currentPin = $scope.confirmPin = '';
|
||||||
|
|
@ -29,13 +29,13 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
||||||
function checkAttempts() {
|
function checkAttempts() {
|
||||||
$scope.currentAttempts += 1;
|
$scope.currentAttempts += 1;
|
||||||
$log.debug('Attempts to unlock:', $scope.currentAttempts);
|
$log.debug('Attempts to unlock:', $scope.currentAttempts);
|
||||||
if ($scope.currentAttempts === 3) {
|
if ($scope.currentAttempts === ATTEMPT_LIMIT) {
|
||||||
$scope.currentAttempts = 0;
|
$scope.currentAttempts = 0;
|
||||||
var limitTime = Math.floor(Date.now() / 1000) + 5 * 60;
|
var limitTime = Math.floor(Date.now() / 1000) + ATTEMPT_LOCK_OUT_TIME;
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
var opts = {
|
var opts = {
|
||||||
lock: {
|
lock: {
|
||||||
method: PIN,
|
method: 'pin',
|
||||||
value: config.lock.value,
|
value: config.lock.value,
|
||||||
bannedUntil: limitTime,
|
bannedUntil: limitTime,
|
||||||
attempts: config.lock.attempts + 1,
|
attempts: config.lock.attempts + 1,
|
||||||
|
|
@ -115,12 +115,12 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
||||||
$scope.save = function() {
|
$scope.save = function() {
|
||||||
if (!$scope.isComplete()) return;
|
if (!$scope.isComplete()) return;
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
$scope.match = config.lock && config.lock.method == PIN && config.lock.value == $scope.currentPin ? true : false;
|
$scope.match = config.lock && config.lock.method == 'pin' && config.lock.value == $scope.currentPin ? true : false;
|
||||||
if (!$scope.locking) {
|
if (!$scope.locking) {
|
||||||
if ($scope.match) {
|
if ($scope.match) {
|
||||||
if ($scope.fromSettings) saveSettings();
|
if ($scope.fromSettings) saveSettings();
|
||||||
else {
|
else {
|
||||||
saveSettings(PIN, $scope.currentPin);
|
saveSettings('pin', $scope.currentPin);
|
||||||
$scope.error = false;
|
$scope.error = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -143,7 +143,7 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
||||||
}, 200);
|
}, 200);
|
||||||
} else {
|
} else {
|
||||||
if ($scope.confirmPin == $scope.currentPin)
|
if ($scope.confirmPin == $scope.currentPin)
|
||||||
saveSettings(PIN, $scope.confirmPin);
|
saveSettings('pin', $scope.confirmPin);
|
||||||
else {
|
else {
|
||||||
$scope.confirmPin = $scope.currentPin = '';
|
$scope.confirmPin = $scope.currentPin = '';
|
||||||
$scope.error = true;
|
$scope.error = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue