1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

model adjustments for new api props

This commit is contained in:
Kyle Spearrin 2017-07-11 13:00:47 -04:00
parent ba6e0d9617
commit c92b346e18
4 changed files with 47 additions and 2 deletions

View File

@ -6,6 +6,7 @@
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;
};

View File

@ -4,8 +4,17 @@ var CipherResponse = function (response) {
this.folderId = response.FolderId;
this.type = response.Type;
this.favorite = response.Favorite;
this.edit = response.Edit;
this.organizationUseTotp = response.OrganizationUseTotp;
this.data = response.Data;
this.revisionDate = response.RevisionDate;
if (response.Attachments) {
this.attachments = [];
for (var i = 0; i < response.Attachments.length; i++) {
this.attachments.push(new AttachmentResponse(response.Attachments[i]));
}
}
};
var FolderResponse = function (response) {
@ -18,24 +27,36 @@ 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;
this.email = response.Email;
this.emailVerified = response.EmailVerified;
this.masterPasswordHint = response.MasterPasswordHint;
this.premium = response.Premium;
this.culture = response.Culture;
this.twoFactorEnabled = response.TwoFactorEnabled;
this.key = response.Key;
@ -58,10 +79,23 @@ var KeysResponse = function (response) {
var ProfileOrganizationResponse = function (response) {
this.id = response.Id;
this.name = response.Name;
this.useGroups = response.UseGroups;
this.useDirectory = response.UseDirectory;
this.useTotp = response.UseTotp;
this.seats = response.Seats;
this.maxCollections = response.MaxCollections;
this.maxStorageGb = response.MaxStorageGb;
this.key = response.Key;
this.status = response.Status;
this.type = response.Type;
this.enabled = response.Enabled;
};
var AttachmentResponse = function (response) {
this.id = response.Id;
this.url = response.Url;
this.fileName = response.FileName;
this.size = response.Size;
this.sizeName = response.SizeName;
};
var IdentityTokenResponse = function (response) {

View File

@ -27,13 +27,15 @@ var LoginData = function (response, userId) {
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.notes = response.notes = response.data.Notes;
this.totp = response.notes = response.data.Totp;
}
else {
throw 'unsupported instance';

View File

@ -100,6 +100,7 @@ var Login = function (obj, alreadyEncrypted) {
this.username = obj.username ? obj.username : null;
this.password = obj.password ? obj.password : null;
this.notes = obj.notes ? obj.notes : null;
this.totp = obj.totp ? obj.totp : null;
}
else {
this.name = obj.name ? new CipherString(obj.name) : null;
@ -107,6 +108,7 @@ var Login = function (obj, alreadyEncrypted) {
this.username = obj.username ? new CipherString(obj.username) : null;
this.password = obj.password ? new CipherString(obj.password) : null;
this.notes = obj.notes ? new CipherString(obj.notes) : null;
this.totp = obj.totp ? new CipherString(obj.totp) : null;
}
};
@ -183,6 +185,12 @@ var Folder = function (obj, alreadyEncrypted) {
return null;
}).then(function (val) {
model.notes = val;
if (self.totp) {
return self.totp.decrypt(self.organizationId);
}
return null;
}).then(function (val) {
model.totp = val;
deferred.resolve(model);
});