Merge pull request #5986 from gabrielbazan7/fix/lockedApp
Fix/locked app
This commit is contained in:
commit
38f8d1151e
14 changed files with 145 additions and 230 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('lockSetupController', function($state, $scope, $timeout, $log, configService, gettextCatalog, fingerprintService, profileService, lodash) {
|
||||
angular.module('copayApp.controllers').controller('lockSetupController', function($state, $rootScope, $scope, $timeout, $log, configService, gettextCatalog, fingerprintService, profileService, lodash, applicationService) {
|
||||
|
||||
function init() {
|
||||
$scope.options = [
|
||||
|
|
@ -53,7 +53,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
o.disabled = false;
|
||||
});
|
||||
|
||||
// HACK: Disable untill we allow to change between methods directly
|
||||
// HACK: Disable until we allow to change between methods directly
|
||||
if (fingerprintService.isAvailable()) {
|
||||
switch (savedMethod) {
|
||||
case 'pin':
|
||||
|
|
@ -120,9 +120,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
function disableMethod(method) {
|
||||
switch (method) {
|
||||
case 'pin':
|
||||
$state.transitionTo('tabs.pin', {
|
||||
action: 'disable'
|
||||
});
|
||||
applicationService.pinModal('disable');
|
||||
break;
|
||||
case 'fingerprint':
|
||||
fingerprintService.check('unlockingApp', function(err) {
|
||||
|
|
@ -136,9 +134,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
function enableMethod(method) {
|
||||
switch (method) {
|
||||
case 'pin':
|
||||
$state.transitionTo('tabs.pin', {
|
||||
action: 'setup'
|
||||
});
|
||||
applicationService.pinModal('setup');
|
||||
break;
|
||||
case 'fingerprint':
|
||||
saveConfig('fingerprint');
|
||||
|
|
@ -159,4 +155,9 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
initMethodSelector();
|
||||
});
|
||||
};
|
||||
|
||||
$rootScope.$on('pinModalClosed', function() {
|
||||
init()
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('lockedViewController', function($state, $scope, $ionicHistory, fingerprintService, appConfigService, gettextCatalog) {
|
||||
$scope.$on("$ionicView.beforeEnter", function(event) {
|
||||
$scope.title = appConfigService.nameCase + ' ' + gettextCatalog.getString('is locked');
|
||||
$scope.appName = appConfigService.name;
|
||||
});
|
||||
|
||||
$scope.requestFingerprint = function() {
|
||||
fingerprintService.check('unlockingApp', function(err) {
|
||||
if (err) return;
|
||||
$state.transitionTo('tabs.home').then(function() {
|
||||
$ionicHistory.clearHistory();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
@ -1,30 +1,25 @@
|
|||
'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, applicationService) {
|
||||
var ATTEMPT_LIMIT = 3;
|
||||
var ATTEMPT_LOCK_OUT_TIME = 5 * 60;
|
||||
var currentPin;
|
||||
currentPin = $scope.confirmPin = '';
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event) {
|
||||
currentPin = $scope.confirmPin = '';
|
||||
$scope.action = $stateParams.action;
|
||||
$scope.match = $scope.error = $scope.disableButtons = false;
|
||||
$scope.currentAttempts = 0;
|
||||
$scope.appName = appConfigService.name;
|
||||
});
|
||||
$scope.match = $scope.error = $scope.disableButtons = false;
|
||||
$scope.currentAttempts = 0;
|
||||
$scope.appName = appConfigService.name;
|
||||
|
||||
$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);
|
||||
if (now < $scope.bannedUntil) {
|
||||
$scope.error = $scope.disableButtons = true;
|
||||
lockTimeControl($scope.bannedUntil);
|
||||
}
|
||||
configService.whenAvailable(function(config) {
|
||||
if (!config.lock) return;
|
||||
$scope.bannedUntil = config.lock.bannedUntil || null;
|
||||
if ($scope.bannedUntil) {
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
if (now < $scope.bannedUntil) {
|
||||
$scope.error = $scope.disableButtons = true;
|
||||
lockTimeControl($scope.bannedUntil);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function getSavedMethod() {
|
||||
|
|
@ -126,7 +121,10 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
|||
}
|
||||
break;
|
||||
case 'check':
|
||||
if (isMatch(currentPin)) return $scope.close();
|
||||
if (isMatch(currentPin)) {
|
||||
$scope.hideModal();
|
||||
return;
|
||||
}
|
||||
showError();
|
||||
checkAttempts();
|
||||
break;
|
||||
|
|
@ -174,7 +172,7 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
|||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
$scope.close();
|
||||
$scope.hideModal();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -189,7 +187,7 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
|||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
$scope.close();
|
||||
$scope.hideModal();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -206,14 +204,4 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
|||
});
|
||||
};
|
||||
|
||||
$scope.close = function(delay) {
|
||||
$timeout(function() {
|
||||
var shouldReturn = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName != 'starting';
|
||||
|
||||
if (shouldReturn)
|
||||
$ionicHistory.goBack()
|
||||
else
|
||||
$state.go('tabs.home');
|
||||
}, delay || 1);
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue