mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-24 12:06:15 +01:00
added ability to pass and parse twofactor provider
This commit is contained in:
parent
f6fc8a4a0f
commit
981fd22ce5
@ -13,11 +13,11 @@ var FolderRequest = function (folder) {
|
||||
this.name = folder.name ? folder.name.encryptedString : null;
|
||||
};
|
||||
|
||||
var TokenRequest = function (email, masterPasswordHash, token, device) {
|
||||
var TokenRequest = function (email, masterPasswordHash, provider, token, device) {
|
||||
this.email = email;
|
||||
this.masterPasswordHash = masterPasswordHash;
|
||||
this.token = token;
|
||||
this.provider = 0; // 0 = Authenticator
|
||||
this.provider = provider;
|
||||
this.device = null;
|
||||
if (device) {
|
||||
this.device = device;
|
||||
|
@ -32,10 +32,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loginPromise = authService.logIn(model.email, model.masterPassword, null);
|
||||
$scope.loginPromise = authService.logIn(model.email, model.masterPassword, null, null);
|
||||
|
||||
$scope.loginPromise.then(function (twoFactor) {
|
||||
if (twoFactor) {
|
||||
$scope.loginPromise.then(function (response) {
|
||||
if (response.twoFactor) {
|
||||
$analytics.eventTrack('Logged In To Two-step');
|
||||
$state.go('twoFactor', {
|
||||
animation: 'in-slide-left',
|
||||
|
@ -18,7 +18,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loginPromise = authService.logIn(email, masterPassword, model.code);
|
||||
$scope.loginPromise = authService.logIn(email, masterPassword, 0, model.code);
|
||||
$scope.loginPromise.then(function () {
|
||||
$analytics.eventTrack('Logged In From Two-step');
|
||||
$state.go('tabs.vault', { animation: 'in-slide-left', syncOnLoad: true });
|
||||
|
@ -5,14 +5,14 @@
|
||||
folderService, settingsService, syncService, appIdService, utilsService) {
|
||||
var _service = {};
|
||||
|
||||
_service.logIn = function (email, masterPassword, twoFactorToken) {
|
||||
_service.logIn = function (email, masterPassword, twoFactorProvider, twoFactorToken) {
|
||||
email = email.toLowerCase();
|
||||
var key = cryptoService.makeKey(masterPassword, email);
|
||||
var deferred = $q.defer();
|
||||
cryptoService.hashPassword(masterPassword, key, function (hashedPassword) {
|
||||
appIdService.getAppId(function (appId) {
|
||||
var deviceRequest = new DeviceRequest(appId, utilsService);
|
||||
var request = new TokenRequest(email, hashedPassword, twoFactorToken, deviceRequest);
|
||||
var request = new TokenRequest(email, hashedPassword, twoFactorProvider, twoFactorToken, deviceRequest);
|
||||
|
||||
apiService.postIdentityToken(request, function (response) {
|
||||
// success
|
||||
@ -27,15 +27,22 @@
|
||||
cryptoService.setEncKey(response.key).then(function () {
|
||||
return cryptoService.setEncPrivateKey(response.privateKey);
|
||||
}).then(function () {
|
||||
loggedIn(deferred);
|
||||
chrome.runtime.sendMessage({ command: 'loggedIn' });
|
||||
deferred.resolve({
|
||||
twoFactor: false,
|
||||
twoFactorProviders: null
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, function () {
|
||||
}, function (providers) {
|
||||
// two factor required
|
||||
deferred.resolve(true);
|
||||
deferred.resolve({
|
||||
twoFactor: true,
|
||||
twoFactorProviders: providers
|
||||
});
|
||||
}, function (error) {
|
||||
// error
|
||||
deferred.reject(error);
|
||||
@ -51,10 +58,5 @@
|
||||
callback();
|
||||
};
|
||||
|
||||
function loggedIn(deferred) {
|
||||
chrome.runtime.sendMessage({ command: 'loggedIn' });
|
||||
deferred.resolve(false);
|
||||
}
|
||||
|
||||
return _service;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user