mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
change email/password adjustments
This commit is contained in:
parent
aa7a3c442c
commit
bc431b896b
@ -77,7 +77,6 @@ angular
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: encryptedFolder.Id,
|
id: encryptedFolder.Id,
|
||||||
'type': 0,
|
|
||||||
name: cryptoService.decrypt(encryptedFolder.Name)
|
name: cryptoService.decrypt(encryptedFolder.Name)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -179,7 +178,6 @@ angular
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: unencryptedFolder.id,
|
id: unencryptedFolder.id,
|
||||||
'type': 0,
|
|
||||||
name: cryptoService.encrypt(unencryptedFolder.name, key)
|
name: cryptoService.encrypt(unencryptedFolder.name, key)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -116,14 +116,26 @@ angular
|
|||||||
return buffer.getBytes(16);
|
return buffer.getBytes(16);
|
||||||
};
|
};
|
||||||
|
|
||||||
_service.getPrivateKey = function () {
|
_service.getPrivateKey = function (outputEncoding) {
|
||||||
|
outputEncoding = outputEncoding || 'native';
|
||||||
|
|
||||||
if (_privateKey) {
|
if (_privateKey) {
|
||||||
|
if (outputEncoding === 'raw') {
|
||||||
|
var privateKeyAsn1 = forge.pki.privateKeyToAsn1(_privateKey);
|
||||||
|
var privateKeyPkcs8 = forge.pki.wrapRsaPrivateKey(privateKeyAsn1);
|
||||||
|
return forge.asn1.toDer(privateKeyPkcs8).getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
return _privateKey;
|
return _privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sessionStorage.privateKey) {
|
if ($sessionStorage.privateKey) {
|
||||||
var privateKeyBytes = forge.util.decode64($sessionStorage.privateKey);
|
var privateKeyBytes = forge.util.decode64($sessionStorage.privateKey);
|
||||||
_privateKey = forge.pki.privateKeyFromAsn1(forge.asn1.fromDer(privateKeyBytes));
|
_privateKey = forge.pki.privateKeyFromAsn1(forge.asn1.fromDer(privateKeyBytes));
|
||||||
|
|
||||||
|
if (outputEncoding === 'raw') {
|
||||||
|
return privateKeyBytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _privateKey;
|
return _privateKey;
|
||||||
|
@ -39,13 +39,23 @@
|
|||||||
reencryptedFolders = cipherService.encryptFolders(unencryptedFolders, _newKey);
|
reencryptedFolders = cipherService.encryptFolders(unencryptedFolders, _newKey);
|
||||||
}).$promise;
|
}).$promise;
|
||||||
|
|
||||||
|
var privateKey = cryptoService.getPrivateKey('raw'),
|
||||||
|
reencryptedPrivateKey = null;
|
||||||
|
if (privateKey) {
|
||||||
|
reencryptedPrivateKey = cryptoService.encrypt(privateKey, _newKey, 'raw');
|
||||||
|
}
|
||||||
|
|
||||||
$q.all([loginsPromise, foldersPromise]).then(function () {
|
$q.all([loginsPromise, foldersPromise]).then(function () {
|
||||||
var request = {
|
var request = {
|
||||||
token: model.token,
|
token: model.token,
|
||||||
newEmail: model.newEmail.toLowerCase(),
|
newEmail: model.newEmail.toLowerCase(),
|
||||||
masterPasswordHash: _masterPasswordHash,
|
masterPasswordHash: _masterPasswordHash,
|
||||||
newMasterPasswordHash: _newMasterPasswordHash,
|
newMasterPasswordHash: _newMasterPasswordHash,
|
||||||
ciphers: reencryptedLogins.concat(reencryptedFolders)
|
data: {
|
||||||
|
ciphers: reencryptedLogins,
|
||||||
|
folders: reencryptedFolders,
|
||||||
|
privateKey: reencryptedPrivateKey
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.confirmPromise = apiService.accounts.email(request, function () {
|
$scope.confirmPromise = apiService.accounts.email(request, function () {
|
||||||
|
@ -39,11 +39,21 @@
|
|||||||
reencryptedFolders = cipherService.encryptFolders(unencryptedFolders, newKey);
|
reencryptedFolders = cipherService.encryptFolders(unencryptedFolders, newKey);
|
||||||
}).$promise;
|
}).$promise;
|
||||||
|
|
||||||
|
var privateKey = cryptoService.getPrivateKey('raw'),
|
||||||
|
reencryptedPrivateKey = null;
|
||||||
|
if (privateKey) {
|
||||||
|
reencryptedPrivateKey = cryptoService.encrypt(privateKey, newKey, 'raw');
|
||||||
|
}
|
||||||
|
|
||||||
$q.all([loginsPromise, foldersPromise]).then(function () {
|
$q.all([loginsPromise, foldersPromise]).then(function () {
|
||||||
var request = {
|
var request = {
|
||||||
masterPasswordHash: cryptoService.hashPassword(model.masterPassword),
|
masterPasswordHash: cryptoService.hashPassword(model.masterPassword),
|
||||||
newMasterPasswordHash: cryptoService.hashPassword(model.newMasterPassword, newKey),
|
newMasterPasswordHash: cryptoService.hashPassword(model.newMasterPassword, newKey),
|
||||||
ciphers: reencryptedLogins.concat(reencryptedFolders)
|
data: {
|
||||||
|
ciphers: reencryptedLogins,
|
||||||
|
folders: reencryptedFolders,
|
||||||
|
privateKey: reencryptedPrivateKey
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.savePromise = apiService.accounts.putPassword(request, function () {
|
$scope.savePromise = apiService.accounts.putPassword(request, function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user