mirror of
https://github.com/bitwarden/web
synced 2025-12-14 07:13:23 +00:00
share login modal
This commit is contained in:
@@ -18,16 +18,22 @@ angular
|
||||
_service.decryptLogin = function (encryptedLogin) {
|
||||
if (!encryptedLogin) throw "encryptedLogin is undefined or null";
|
||||
|
||||
var key = null;
|
||||
if (encryptedLogin.Key) {
|
||||
key = cryptoService.rsaDecrypt(encryptedLogin.Key);
|
||||
}
|
||||
|
||||
var login = {
|
||||
id: encryptedLogin.Id,
|
||||
'type': 1,
|
||||
folderId: encryptedLogin.FolderId,
|
||||
favorite: encryptedLogin.Favorite,
|
||||
name: cryptoService.decrypt(encryptedLogin.Name),
|
||||
uri: encryptedLogin.Uri && encryptedLogin.Uri !== '' ? cryptoService.decrypt(encryptedLogin.Uri) : null,
|
||||
username: encryptedLogin.Username && encryptedLogin.Username !== '' ? cryptoService.decrypt(encryptedLogin.Username) : null,
|
||||
password: encryptedLogin.Password && encryptedLogin.Password !== '' ? cryptoService.decrypt(encryptedLogin.Password) : null,
|
||||
notes: encryptedLogin.Notes && encryptedLogin.Notes !== '' ? cryptoService.decrypt(encryptedLogin.Notes) : null
|
||||
name: cryptoService.decrypt(encryptedLogin.Name, key),
|
||||
uri: encryptedLogin.Uri && encryptedLogin.Uri !== '' ? cryptoService.decrypt(encryptedLogin.Uri, key) : null,
|
||||
username: encryptedLogin.Username && encryptedLogin.Username !== '' ? cryptoService.decrypt(encryptedLogin.Username, key) : null,
|
||||
password: encryptedLogin.Password && encryptedLogin.Password !== '' ? cryptoService.decrypt(encryptedLogin.Password, key) : null,
|
||||
notes: encryptedLogin.Notes && encryptedLogin.Notes !== '' ? cryptoService.decrypt(encryptedLogin.Notes, key) : null,
|
||||
key: encryptedLogin.Key
|
||||
};
|
||||
|
||||
if (encryptedLogin.Folder) {
|
||||
@@ -39,6 +45,40 @@ angular
|
||||
return login;
|
||||
};
|
||||
|
||||
_service.decryptLoginPreview = function (encryptedCipher) {
|
||||
if (!encryptedCipher) throw "encryptedCipher is undefined or null";
|
||||
|
||||
var key = null;
|
||||
if (encryptedCipher.Key) {
|
||||
key = cryptoService.rsaDecrypt(encryptedCipher.Key);
|
||||
}
|
||||
|
||||
var login = {
|
||||
id: encryptedCipher.Id,
|
||||
folderId: encryptedCipher.FolderId,
|
||||
favorite: encryptedCipher.Favorite,
|
||||
name: decryptProperty(encryptedCipher.Data.Name, key, false),
|
||||
username: decryptProperty(encryptedCipher.Data.Username, key, true)
|
||||
};
|
||||
|
||||
try {
|
||||
login.name = cryptoService.decrypt(encryptedCipher.Data.Name, key);
|
||||
}
|
||||
catch (err) {
|
||||
login.name = '[error: cannot decrypt]';
|
||||
}
|
||||
|
||||
try {
|
||||
login.username = encryptedCipher.Data.Username && encryptedCipher.Data.Username !== '' ?
|
||||
cryptoService.decrypt(encryptedCipher.Data.Username, key) : null;
|
||||
}
|
||||
catch (err) {
|
||||
login.username = '[error: cannot decrypt]';
|
||||
}
|
||||
|
||||
return login;
|
||||
};
|
||||
|
||||
_service.decryptFolders = function (encryptedFolders) {
|
||||
if (!encryptedFolders) throw "encryptedFolders is undefined or null";
|
||||
|
||||
@@ -60,6 +100,30 @@ angular
|
||||
};
|
||||
};
|
||||
|
||||
_service.decryptFolderPreview = function (encryptedFolder) {
|
||||
if (!encryptedFolder) throw "encryptedFolder is undefined or null";
|
||||
|
||||
return {
|
||||
id: encryptedFolder.Id,
|
||||
name: decryptProperty(encryptedFolder.Data.Name, null, false)
|
||||
};
|
||||
};
|
||||
|
||||
function decryptProperty(property, key, checkEmpty) {
|
||||
if (checkEmpty && (!property || property === '')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
property = cryptoService.decrypt(property, key);
|
||||
}
|
||||
catch (err) {
|
||||
property = '[error: cannot decrypt]';
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
_service.encryptLogins = function (unencryptedLogins, key) {
|
||||
if (!unencryptedLogins) throw "unencryptedLogins is undefined or null";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user