1
0
mirror of https://github.com/bitwarden/server synced 2026-01-06 10:34:01 +00:00

refactored data storage to use cipher table. added history table and insert triggers.

This commit is contained in:
Kyle Spearrin
2016-05-21 17:16:22 -04:00
parent 8137847485
commit 3fdb0fcf67
56 changed files with 422 additions and 646 deletions

View File

@@ -1,21 +1,29 @@
using System;
using Bit.Core.Domains;
using Newtonsoft.Json;
namespace Bit.Api.Models
{
public class FolderResponseModel : ResponseModel
{
public FolderResponseModel(Folder folder)
public FolderResponseModel(Cipher cipher)
: base("folder")
{
if(folder == null)
if(cipher == null)
{
throw new ArgumentNullException(nameof(folder));
throw new ArgumentNullException(nameof(cipher));
}
Id = folder.Id;
Name = folder.Name;
RevisionDate = folder.RevisionDate;
if(cipher.Type != Core.Enums.CipherType.Folder)
{
throw new ArgumentException(nameof(cipher.Type));
}
var data = JsonConvert.DeserializeObject<CipherDataModel>(cipher.Data);
Id = cipher.Id.ToString();
Name = data.Name;
RevisionDate = cipher.RevisionDate;
}
public string Id { get; set; }

View File

@@ -13,7 +13,7 @@ namespace Bit.Api.Models
throw new ArgumentNullException(nameof(user));
}
Id = user.Id;
Id = user.Id.ToString();
Name = user.Name;
Email = user.Email;
MasterPasswordHint = string.IsNullOrWhiteSpace(user.MasterPasswordHint) ? null : user.MasterPasswordHint;

View File

@@ -1,26 +1,34 @@
using System;
using Bit.Core.Domains;
using Newtonsoft.Json;
namespace Bit.Api.Models
{
public class SiteResponseModel : ResponseModel
{
public SiteResponseModel(Site site)
public SiteResponseModel(Cipher cipher)
: base("site")
{
if(site == null)
if(cipher == null)
{
throw new ArgumentNullException(nameof(site));
throw new ArgumentNullException(nameof(cipher));
}
Id = site.Id;
FolderId = string.IsNullOrWhiteSpace(site.FolderId) ? null : site.FolderId;
Name = site.Name;
Uri = site.Uri;
Username = site.Username;
Password = site.Password;
Notes = site.Notes;
RevisionDate = site.RevisionDate;
if(cipher.Type != Core.Enums.CipherType.Site)
{
throw new ArgumentException(nameof(cipher.Type));
}
var data = JsonConvert.DeserializeObject<CipherDataModel>(cipher.Data);
Id = cipher.Id.ToString();
FolderId = cipher.FolderId?.ToString();
Name = data.Name;
Uri = data.Uri;
Username = data.Username;
Password = data.Password;
Notes = data.Notes;
RevisionDate = cipher.RevisionDate;
}
public string Id { get; set; }