mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
pub/priv keys and share updates
This commit is contained in:
@ -7,7 +7,7 @@ namespace Bit.Api.Models
|
||||
{
|
||||
public string PublicKey { get; set; }
|
||||
[Required]
|
||||
public string PrivateKey { get; set; }
|
||||
public string EncryptedPrivateKey { get; set; }
|
||||
|
||||
public User ToUser(User existingUser)
|
||||
{
|
||||
@ -16,7 +16,7 @@ namespace Bit.Api.Models
|
||||
existingUser.PublicKey = PublicKey;
|
||||
}
|
||||
|
||||
existingUser.PrivateKey = PrivateKey;
|
||||
existingUser.PrivateKey = EncryptedPrivateKey;
|
||||
return existingUser;
|
||||
}
|
||||
}
|
||||
|
@ -12,19 +12,27 @@ namespace Bit.Api.Models
|
||||
[StringLength(50)]
|
||||
public string Email { get; set; }
|
||||
[Required]
|
||||
[StringLength(300)]
|
||||
[StringLength(1000)]
|
||||
public string MasterPasswordHash { get; set; }
|
||||
[StringLength(50)]
|
||||
public string MasterPasswordHint { get; set; }
|
||||
public KeysRequestModel Keys { get; set; }
|
||||
|
||||
public User ToUser()
|
||||
{
|
||||
return new User
|
||||
var user = new User
|
||||
{
|
||||
Name = Name,
|
||||
Email = Email,
|
||||
MasterPasswordHint = MasterPasswordHint
|
||||
};
|
||||
|
||||
if(Keys != null)
|
||||
{
|
||||
Keys.ToUser(user);
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,16 +33,6 @@ 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; }
|
||||
|
@ -26,16 +26,6 @@ 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; }
|
||||
|
@ -32,16 +32,6 @@ 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; }
|
||||
|
Reference in New Issue
Block a user