mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
cipher share data and key response
This commit is contained in:
@ -7,7 +7,7 @@ namespace Bit.Api.Models
|
||||
{
|
||||
public class CipherHistoryResponseModel : ResponseModel
|
||||
{
|
||||
public CipherHistoryResponseModel(IEnumerable<Cipher> revisedCiphers, IEnumerable<Guid> deletedIds)
|
||||
public CipherHistoryResponseModel(IEnumerable<Cipher> revisedCiphers, IEnumerable<Guid> deletedIds, Guid userId)
|
||||
: base("cipherHistory")
|
||||
{
|
||||
if(revisedCiphers == null)
|
||||
@ -20,7 +20,7 @@ namespace Bit.Api.Models
|
||||
throw new ArgumentNullException(nameof(deletedIds));
|
||||
}
|
||||
|
||||
Revised = revisedCiphers.Select(c => new CipherResponseModel(c));
|
||||
Revised = revisedCiphers.Select(c => new CipherResponseModel(c, userId));
|
||||
Deleted = deletedIds.Select(id => id.ToString());
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class CipherResponseModel : ResponseModel
|
||||
{
|
||||
public CipherResponseModel(Cipher cipher)
|
||||
public CipherResponseModel(Cipher cipher, Guid userId)
|
||||
: base("cipher")
|
||||
{
|
||||
if(cipher == null)
|
||||
@ -30,6 +33,16 @@ namespace Bit.Api.Models
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
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; }
|
||||
@ -37,6 +50,7 @@ namespace Bit.Api.Models
|
||||
public Core.Enums.CipherType Type { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public dynamic Data { get; set; }
|
||||
public string Key { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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 LoginResponseModel : ResponseModel
|
||||
{
|
||||
public LoginResponseModel(Cipher cipher)
|
||||
public LoginResponseModel(Cipher cipher, Guid userId)
|
||||
: base("login")
|
||||
{
|
||||
if(cipher == null)
|
||||
@ -29,6 +32,16 @@ namespace Bit.Api.Models
|
||||
Password = data.Password;
|
||||
Notes = data.Notes;
|
||||
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; }
|
||||
@ -39,6 +52,7 @@ namespace Bit.Api.Models
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string Key { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
|
||||
// Expandables
|
||||
|
Reference in New Issue
Block a user