1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

cleanup event listeners for u2f

This commit is contained in:
Kyle Spearrin
2017-07-26 00:20:30 -04:00
parent 21d4f9e193
commit 01ccd21ef3
2 changed files with 82 additions and 63 deletions

View File

@@ -7,16 +7,19 @@
utilsService.initListSectionItemListeners($(document), angular);
var u2f = new U2f(function (data) {
$scope.login(data);
$scope.$apply();
$timeout(function () {
$scope.login(data);
});
}, function (error) {
toastr.error(error, i18nService.errorsOccurred);
$scope.$apply();
$timeout(function () {
toastr.error(error, i18nService.errorsOccurred);
});
}, function (info) {
if (info === 'ready') {
$scope.u2fReady = true;
}
$scope.$apply();
$timeout(function () {
if (info === 'ready') {
$scope.u2fReady = true;
}
});
});
var constants = constantsService;
@@ -62,7 +65,6 @@
$scope.loginPromise.then(function () {
$analytics.eventTrack('Logged In From Two-step');
$state.go('tabs.vault', { animation: 'in-slide-left', syncOnLoad: true });
u2f = null;
}, function () {
u2f.start();
});
@@ -87,8 +89,6 @@
};
$scope.anotherMethod = function () {
u2f.stop();
u2f = null;
$state.go('twoFactorMethods', {
animation: 'in-slide-up',
email: email,
@@ -99,13 +99,17 @@
};
$scope.back = function () {
u2f.stop();
u2f = null;
$state.go('login', {
animation: 'out-slide-right'
});
};
$scope.$on('$destroy', function () {
u2f.stop();
u2f.cleanup();
u2f = null;
});
function getDefaultProvider(twoFactorProviders) {
var keys = Object.keys(twoFactorProviders);
var providerType = null;
@@ -127,6 +131,7 @@
function init() {
u2f.stop();
u2f.cleanup();
$timeout(function () {
$('#code').focus();