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

Support for CipherKey and Share APIs

This commit is contained in:
Kyle Spearrin
2017-02-27 22:58:01 -05:00
parent 48cf44f5b2
commit 8c7f1dd343
27 changed files with 144 additions and 53 deletions

View File

@ -1,8 +1,6 @@
using System;
using Bit.Core.Domains;
using Bit.Core.Models.Data;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Bit.Api.Models
{
@ -21,6 +19,7 @@ namespace Bit.Api.Models
Type = cipher.Type;
Favorite = cipher.Favorite;
RevisionDate = cipher.RevisionDate;
Key = cipher.Key;
switch(cipher.Type)
{
@ -39,6 +38,7 @@ namespace Bit.Api.Models
public string FolderId { get; set; }
public Core.Enums.CipherType Type { get; set; }
public bool Favorite { get; set; }
public string Key { get; set; }
public dynamic Data { get; set; }
public DateTime RevisionDate { get; set; }
}
@ -48,14 +48,11 @@ namespace Bit.Api.Models
public CipherShareResponseModel(CipherShare cipherShare, Guid userId)
: base(cipherShare, userId, "cipherShare")
{
Key = cipherShare.Key;
Permissions = cipherShare.Permissions == null ? null :
JsonConvert.DeserializeObject<IEnumerable<Core.Enums.SharePermissionType>>(cipherShare.Permissions);
ReadOnly = cipherShare.ReadOnly;
Status = cipherShare.Status;
}
public string Key { get; set; }
public IEnumerable<Core.Enums.SharePermissionType> Permissions { get; set; }
public bool ReadOnly { get; set; }
public Core.Enums.ShareStatusType? Status { get; set; }
}
}

View File

@ -1,8 +1,5 @@
using System;
using Bit.Core.Domains;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
namespace Bit.Api.Models
{
@ -30,7 +27,6 @@ namespace Bit.Api.Models
public string Id { get; set; }
public string Name { get; set; }
public string Key { get; set; }
public DateTime RevisionDate { get; set; }
}
}

View File

@ -1,14 +1,12 @@
using System;
using Bit.Core.Domains;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using Bit.Core.Models.Data;
namespace Bit.Api.Models
{
public class LoginResponseModel : ResponseModel
{
public LoginResponseModel(Cipher cipher, Guid userId)
public LoginResponseModel(Cipher cipher, Guid userId, string obj = "login")
: base("login")
{
if(cipher == null)
@ -32,6 +30,7 @@ namespace Bit.Api.Models
Password = data.Password;
Notes = data.Notes;
RevisionDate = cipher.RevisionDate;
Key = cipher.Key;
}
public string Id { get; set; }
@ -42,10 +41,23 @@ 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; }
public string Key { get; set; }
// Expandables
public FolderResponseModel Folder { get; set; }
}
public class LoginShareResponseModel : LoginResponseModel
{
public LoginShareResponseModel(CipherShare cipherShare, Guid userId)
: base(cipherShare, userId, "loginShare")
{
ReadOnly = cipherShare.ReadOnly;
Status = cipherShare.Status;
}
public bool ReadOnly { get; set; }
public Core.Enums.ShareStatusType? Status { get; set; }
}
}

View File

@ -1,7 +1,5 @@
using System;
using Bit.Core.Domains;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Bit.Api.Models
{
@ -20,8 +18,7 @@ namespace Bit.Api.Models
SharerUserId = share.SharerUserId.ToString();
CipherId = share.CipherId.ToString();
Key = Key;
Permissions = share.Permissions == null ? null :
JsonConvert.DeserializeObject<IEnumerable<Core.Enums.SharePermissionType>>(share.Permissions);
ReadOnly = share.ReadOnly;
Status = share.Status;
}
@ -30,7 +27,7 @@ namespace Bit.Api.Models
public string SharerUserId { get; set; }
public string CipherId { get; set; }
public string Key { get; set; }
public IEnumerable<Core.Enums.SharePermissionType> Permissions { get; set; }
public bool ReadOnly { get; set; }
public Core.Enums.ShareStatusType? Status { get; set; }
}
}