1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

move from login to cipher apis

This commit is contained in:
Kyle Spearrin
2017-09-20 17:13:38 -04:00
parent b48c86a572
commit 8a1e8678f8
5 changed files with 54 additions and 153 deletions

View File

@@ -1,13 +1,18 @@
var LoginRequest = function (login) {
this.folderId = login.folderId;
this.organizationId = login.organizationId;
this.name = login.name ? login.name.encryptedString : null;
this.uri = login.uri ? login.uri.encryptedString : null;
this.username = login.username ? login.username.encryptedString : null;
this.password = login.password ? login.password.encryptedString : null;
this.notes = login.notes ? login.notes.encryptedString : null;
this.totp = login.totp ? login.totp.encryptedString : null;
this.favorite = login.favorite;
var CipherRequest = function (cipher, type) {
this.type = type;
this.folderId = cipher.folderId;
this.organizationId = cipher.organizationId;
this.name = cipher.name ? cipher.name.encryptedString : null;
this.favorite = cipher.favorite;
if (type === 1) {
// login
this.uri = cipher.uri ? cipher.uri.encryptedString : null;
this.username = cipher.username ? cipher.username.encryptedString : null;
this.password = cipher.password ? cipher.password.encryptedString : null;
this.totp = cipher.totp ? cipher.totp.encryptedString : null;
this.notes = cipher.notes ? cipher.notes.encryptedString : null;
}
};
var FolderRequest = function (folder) {

View File

@@ -23,33 +23,6 @@ var FolderResponse = function (response) {
this.revisionDate = response.RevisionDate;
};
var LoginResponse = function (response) {
this.id = response.Id;
this.organizationId = response.OrganizationId;
this.folderId = response.FolderId;
this.edit = response.Edit;
this.name = response.Name;
this.uri = response.Uri;
this.username = response.Username;
this.password = response.Password;
this.notes = response.Notes;
this.totp = response.Totp;
this.favorite = response.Favorite;
this.revisionDate = response.RevisionDate;
this.organizationUseTotp = response.OrganizationUseTotp;
if (response.Folder) {
this.folder = new FolderResponse(response.Folder);
}
if (response.Attachments) {
this.attachments = [];
for (var i = 0; i < response.Attachments.length; i++) {
this.attachments.push(new AttachmentResponse(response.Attachments[i]));
}
}
};
var ProfileResponse = function (response) {
this.id = response.Id;
this.name = response.Name;

View File

@@ -22,27 +22,12 @@ var LoginData = function (response, userId) {
this.userId = userId;
this.edit = response.edit;
this.organizationUseTotp = response.organizationUseTotp;
if (response instanceof LoginResponse) {
this.name = response.name;
this.uri = response.uri;
this.username = response.username;
this.password = response.password;
this.notes = response.notes;
this.totp = response.totp;
}
else if (response instanceof CipherResponse) {
this.name = response.data.Name;
this.uri = response.data.Uri;
this.username = response.data.Username;
this.password = response.data.Password;
this.notes = response.notes = response.data.Notes;
this.totp = response.notes = response.data.Totp;
}
else {
throw 'unsupported instance';
}
this.name = response.data.Name;
this.uri = response.data.Uri;
this.username = response.data.Username;
this.password = response.data.Password;
this.notes = response.notes = response.data.Notes;
this.totp = response.notes = response.data.Totp;
this.favorite = response.favorite;
this.revisionDate = response.revisionDate;