mirror of
https://github.com/bitwarden/server
synced 2025-12-10 13:23:27 +00:00
28 lines
736 B
C#
28 lines
736 B
C#
using System.ComponentModel.DataAnnotations;
|
|
using Bit.Core.Entities;
|
|
|
|
namespace Bit.Api.Models.Request.Accounts
|
|
{
|
|
public class KeysRequestModel
|
|
{
|
|
public string PublicKey { get; set; }
|
|
[Required]
|
|
public string EncryptedPrivateKey { get; set; }
|
|
|
|
public User ToUser(User existingUser)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(existingUser.PublicKey) && !string.IsNullOrWhiteSpace(PublicKey))
|
|
{
|
|
existingUser.PublicKey = PublicKey;
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(existingUser.PrivateKey))
|
|
{
|
|
existingUser.PrivateKey = EncryptedPrivateKey;
|
|
}
|
|
|
|
return existingUser;
|
|
}
|
|
}
|
|
}
|