1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-11 16:55:56 +01:00

send key with auth app setup

This commit is contained in:
Kyle Spearrin 2017-06-20 10:12:18 -04:00
parent e49948b512
commit 4db5c96781

View File

@ -6,7 +6,8 @@
$analytics.eventTrack('settingsTwoStepAuthenticatorController', { category: 'Modal' }); $analytics.eventTrack('settingsTwoStepAuthenticatorController', { category: 'Modal' });
var _issuer = 'bitwarden', var _issuer = 'bitwarden',
_profile = null, _profile = null,
_masterPasswordHash; _masterPasswordHash
_key = null;
$scope.auth = function (model) { $scope.auth = function (model) {
_masterPasswordHash = cryptoService.hashPassword(model.masterPassword); _masterPasswordHash = cryptoService.hashPassword(model.masterPassword);
@ -34,12 +35,13 @@
function processResponse(response) { function processResponse(response) {
$scope.enabled = response.Enabled; $scope.enabled = response.Enabled;
_key = response.Key;
$scope.model = { $scope.model = {
key: formatString(response.Key), key: formatString(_key),
qr: 'https://chart.googleapis.com/chart?chs=120x120&chld=L|0&cht=qr&chl=otpauth://totp/' + qr: 'https://chart.googleapis.com/chart?chs=120x120&chld=L|0&cht=qr&chl=otpauth://totp/' +
_issuer + ':' + encodeURIComponent(_profile.email) + _issuer + ':' + encodeURIComponent(_profile.email) +
'%3Fsecret=' + encodeURIComponent(response.Key) + '%3Fsecret=' + encodeURIComponent(_key) +
'%26issuer=' + _issuer '%26issuer=' + _issuer
}; };
$scope.updateModel = { $scope.updateModel = {
@ -74,6 +76,7 @@
function update(model) { function update(model) {
$scope.submitPromise = apiService.twoFactor.putAuthenticator({}, { $scope.submitPromise = apiService.twoFactor.putAuthenticator({}, {
token: model.token.replace(' ', ''), token: model.token.replace(' ', ''),
key: _key,
masterPasswordHash: _masterPasswordHash masterPasswordHash: _masterPasswordHash
}, function (response) { }, function (response) {
$analytics.eventTrack('Enabled Two-step Authenticator'); $analytics.eventTrack('Enabled Two-step Authenticator');