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:
@ -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; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user