1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 00:22:50 -05:00

cipher share data and key response

This commit is contained in:
Kyle Spearrin
2017-02-18 01:17:09 -05:00
parent f7be17d1c5
commit 2b72197f0a
13 changed files with 105 additions and 34 deletions

View File

@ -1,11 +1,14 @@
using System;
using Bit.Core.Domains;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
namespace Bit.Api.Models
{
public class FolderResponseModel : ResponseModel
{
public FolderResponseModel(Cipher cipher)
public FolderResponseModel(Cipher cipher, Guid userId)
: base("folder")
{
if(cipher == null)
@ -23,10 +26,21 @@ namespace Bit.Api.Models
Id = cipher.Id.ToString();
Name = data.Name;
RevisionDate = cipher.RevisionDate;
if(!string.IsNullOrWhiteSpace(cipher.Shares))
{
var shares = JsonConvert.DeserializeObject<IEnumerable<Cipher.Share>>(cipher.Shares);
var userShare = shares.FirstOrDefault(s => s.UserId == userId);
if(userShare != null)
{
Key = userShare.Key;
}
}
}
public string Id { get; set; }
public string Name { get; set; }
public string Key { get; set; }
public DateTime RevisionDate { get; set; }
}
}