1
0
mirror of https://github.com/bitwarden/web synced 2026-01-02 08:33:18 +00:00

duo 2fa config and login with web sdk

This commit is contained in:
Kyle Spearrin
2017-06-21 15:17:44 -04:00
parent 2f3035a08f
commit ca9a0b072e
14 changed files with 262 additions and 12 deletions

View File

@@ -0,0 +1,75 @@
angular
.module('bit.settings')
.controller('settingsTwoStepDuoController', function ($scope, apiService, $uibModalInstance, cryptoService,
toastr, $analytics, constants) {
$analytics.eventTrack('settingsTwoStepDuoController', { category: 'Modal' });
var _masterPasswordHash;
$scope.updateModel = {
token: null,
host: null,
ikey: null,
skey: null
};
$scope.auth = function (model) {
_masterPasswordHash = cryptoService.hashPassword(model.masterPassword);
$scope.authPromise = apiService.twoFactor.getDuo({}, {
masterPasswordHash: _masterPasswordHash
}).$promise.then(function (apiResponse) {
processResult(apiResponse);
$scope.authed = true;
});
};
$scope.submit = function (model) {
if ($scope.enabled) {
disable();
return;
}
update(model);
};
function disable() {
if (!confirm('Are you sure you want to disable the Duo provider?')) {
return;
}
$scope.submitPromise = apiService.twoFactor.disable({}, {
masterPasswordHash: _masterPasswordHash,
type: constants.twoFactorProvider.duo
}, function (response) {
$analytics.eventTrack('Disabled Two-step Duo');
toastr.success('Duo has been disabled.');
$scope.enabled = response.Enabled;
$scope.close();
}).$promise;
}
function update(model) {
$scope.submitPromise = apiService.twoFactor.putDuo({}, {
integrationKey: model.ikey,
secretKey: model.skey,
host: model.host,
masterPasswordHash: _masterPasswordHash
}, function (response) {
$analytics.eventTrack('Enabled Two-step Duo');
processResult(response);
}).$promise;
}
function processResult(response) {
$scope.enabled = response.Enabled;
$scope.updateModel = {
ikey: response.IntegrationKey,
skey: response.SecretKey,
host: response.Host
};
}
$scope.close = function () {
$uibModalInstance.close($scope.enabled);
};
});