mirror of
https://github.com/bitwarden/server
synced 2025-12-15 07:43:54 +00:00
Update
This commit is contained in:
@@ -446,14 +446,14 @@ public class AccountsController : Controller
|
|||||||
|
|
||||||
if (model.AccountKeys != null)
|
if (model.AccountKeys != null)
|
||||||
{
|
{
|
||||||
await _setAccountKeysForUserCommand.SetAccountKeysForUserAsync(user.Id, model.AccountKeys);
|
await _setAccountKeysForUserCommand.SetAccountKeysForUserAsync(user, model.AccountKeys);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _userService.SaveUserAsync(model.ToUser(user));
|
await _userService.SaveUserAsync(model.ToUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new KeysResponseModel(user);
|
return new KeysResponseModel(model.AccountKeys.ToAccountKeysData(), user.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("keys")]
|
[HttpGet("keys")]
|
||||||
@@ -465,7 +465,8 @@ public class AccountsController : Controller
|
|||||||
throw new UnauthorizedAccessException();
|
throw new UnauthorizedAccessException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new KeysResponseModel(user);
|
var accountKeys = await _userAccountKeysQuery.Run(user);
|
||||||
|
return new KeysResponseModel(accountKeys, user.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
|
|||||||
@@ -1,27 +1,32 @@
|
|||||||
// FIXME: Update this file to be null safe and then delete the line below
|
using Bit.Core.KeyManagement.Models.Api.Response;
|
||||||
#nullable disable
|
using Bit.Core.KeyManagement.Models.Data;
|
||||||
|
|
||||||
using Bit.Core.Entities;
|
|
||||||
using Bit.Core.Models.Api;
|
using Bit.Core.Models.Api;
|
||||||
|
|
||||||
namespace Bit.Api.Models.Response;
|
namespace Bit.Api.Models.Response;
|
||||||
|
|
||||||
public class KeysResponseModel : ResponseModel
|
public class KeysResponseModel : ResponseModel
|
||||||
{
|
{
|
||||||
public KeysResponseModel(User user)
|
public KeysResponseModel(UserAccountKeysData accountKeys, string? masterKeyWrappedUserKey)
|
||||||
: base("keys")
|
: base("keys")
|
||||||
{
|
{
|
||||||
if (user == null)
|
if (masterKeyWrappedUserKey != null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(user));
|
Key = masterKeyWrappedUserKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key = user.Key;
|
PublicKey = accountKeys.PublicKeyEncryptionKeyPairData.PublicKey;
|
||||||
PublicKey = user.PublicKey;
|
PrivateKey = accountKeys.PublicKeyEncryptionKeyPairData.WrappedPrivateKey;
|
||||||
PrivateKey = user.PrivateKey;
|
AccountKeys = new PrivateKeysResponseModel(accountKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Key { get; set; }
|
/// <summary>
|
||||||
|
/// The master key wrapped user key. The master key can either be a master-password master key or a
|
||||||
|
/// key-connector master key.
|
||||||
|
/// </summary>
|
||||||
|
public string? Key { get; set; }
|
||||||
|
[Obsolete("Use AccountKeys.PublicKeyEncryptionKeyPair.PublicKey instead")]
|
||||||
public string PublicKey { get; set; }
|
public string PublicKey { get; set; }
|
||||||
|
[Obsolete("Use AccountKeys.PublicKeyEncryptionKeyPair.WrappedPrivateKey instead")]
|
||||||
public string PrivateKey { get; set; }
|
public string PrivateKey { get; set; }
|
||||||
|
public PrivateKeysResponseModel AccountKeys { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user