1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-10 06:08:34 +02:00
bitwarden-browser/src/app/accounts/accountsTwoFactorMethodsController.js

41 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-06-20 23:06:14 +02:00
angular
.module('bit.accounts')
.controller('accountsTwoFactorMethodsController', function ($scope, $uibModalInstance, $analytics, providers, constants) {
$analytics.eventTrack('accountsTwoFactorMethodsController', { category: 'Modal' });
$scope.providers = [];
if (providers.hasOwnProperty(constants.twoFactorProvider.authenticator)) {
2017-06-23 18:39:56 +02:00
add(constants.twoFactorProvider.authenticator);
2017-06-20 23:06:14 +02:00
}
if (providers.hasOwnProperty(constants.twoFactorProvider.yubikey)) {
2017-06-23 18:39:56 +02:00
add(constants.twoFactorProvider.yubikey);
2017-06-20 23:06:14 +02:00
}
if (providers.hasOwnProperty(constants.twoFactorProvider.email)) {
2017-06-23 18:39:56 +02:00
add(constants.twoFactorProvider.email);
2017-06-20 23:06:14 +02:00
}
if (providers.hasOwnProperty(constants.twoFactorProvider.duo)) {
2017-06-23 18:39:56 +02:00
add(constants.twoFactorProvider.duo);
2017-06-20 23:06:14 +02:00
}
if (providers.hasOwnProperty(constants.twoFactorProvider.u2f)) {
2017-06-23 18:39:56 +02:00
add(constants.twoFactorProvider.u2f);
2017-06-20 23:06:14 +02:00
}
$scope.choose = function (provider) {
2017-06-23 18:39:56 +02:00
$uibModalInstance.close(provider.type);
2017-06-20 23:06:14 +02:00
};
$scope.close = function () {
$uibModalInstance.dismiss('close');
};
2017-06-23 18:39:56 +02:00
function add(type) {
for (var i = 0; i < constants.twoFactorProviderInfo.length; i++) {
if (constants.twoFactorProviderInfo[i].type === type) {
$scope.providers.push(constants.twoFactorProviderInfo[i]);
}
}
}
2017-06-20 23:06:14 +02:00
});