mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 17:12:49 -05:00
refactor for cipher details, folders, favorites
This commit is contained in:
@ -39,15 +39,12 @@ namespace Bit.Core.Models.Api
|
||||
{
|
||||
Id = new Guid(Id),
|
||||
UserId = userId,
|
||||
FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId),
|
||||
//FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId),
|
||||
Type = Type
|
||||
};
|
||||
|
||||
switch(Type)
|
||||
{
|
||||
case CipherType.Folder:
|
||||
cipher.Data = JsonConvert.SerializeObject(new FolderDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
break;
|
||||
case CipherType.Login:
|
||||
cipher.Data = JsonConvert.SerializeObject(new LoginDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
break;
|
||||
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Models.Table;
|
||||
using Newtonsoft.Json;
|
||||
using Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
@ -28,21 +29,22 @@ namespace Bit.Core.Models.Api
|
||||
[StringLength(10000)]
|
||||
public string Notes { get; set; }
|
||||
|
||||
public Cipher ToCipher(Guid userId)
|
||||
public CipherDetails ToCipher(Guid userId)
|
||||
{
|
||||
return ToCipher(new Cipher
|
||||
return ToCipher(new CipherDetails
|
||||
{
|
||||
UserId = userId
|
||||
});
|
||||
}
|
||||
|
||||
public Cipher ToCipher(Cipher existingLogin)
|
||||
public CipherDetails ToCipher(CipherDetails existingLogin)
|
||||
{
|
||||
existingLogin.FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId);
|
||||
existingLogin.Favorite = Favorite;
|
||||
|
||||
existingLogin.Data = JsonConvert.SerializeObject(new LoginDataModel(this),
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
existingLogin.Type = Core.Enums.CipherType.Login;
|
||||
existingLogin.Type = Enums.CipherType.Login;
|
||||
|
||||
return existingLogin;
|
||||
}
|
||||
|
Reference in New Issue
Block a user