mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
public and private keys added to db and user domain. added account APIs got getting and putting keys.
This commit is contained in:
23
src/Api/Models/Request/Accounts/KeysRequestModel.cs
Normal file
23
src/Api/Models/Request/Accounts/KeysRequestModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Bit.Core.Domains;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class KeysRequestModel
|
||||
{
|
||||
public string PublicKey { get; set; }
|
||||
[Required]
|
||||
public string PrivateKey { get; set; }
|
||||
|
||||
public User ToUser(User existingUser)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(PublicKey))
|
||||
{
|
||||
existingUser.PublicKey = PublicKey;
|
||||
}
|
||||
|
||||
existingUser.PrivateKey = PrivateKey;
|
||||
return existingUser;
|
||||
}
|
||||
}
|
||||
}
|
23
src/Api/Models/Response/KeysResponseModel.cs
Normal file
23
src/Api/Models/Response/KeysResponseModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class KeysResponseModel : ResponseModel
|
||||
{
|
||||
public KeysResponseModel(User user)
|
||||
: base("keys")
|
||||
{
|
||||
if(user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
PublicKey = user.PublicKey;
|
||||
PrivateKey = user.PrivateKey;
|
||||
}
|
||||
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user