mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
[PM-23183] Add logger data before throwing for mismatched encryptedFor (#6078)
This commit is contained in:
@@ -157,6 +157,7 @@ public class CiphersController : Controller
|
||||
{
|
||||
if (model.EncryptedFor != user.Id)
|
||||
{
|
||||
_logger.LogError("Cipher was not encrypted for the current user. CurrentUser: {CurrentUserId}, EncryptedFor: {EncryptedFor}", user.Id, model.EncryptedFor);
|
||||
throw new BadRequestException("Cipher was not encrypted for the current user. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -186,6 +187,7 @@ public class CiphersController : Controller
|
||||
{
|
||||
if (model.Cipher.EncryptedFor != user.Id)
|
||||
{
|
||||
_logger.LogError("Cipher was not encrypted for the current user. CurrentUser: {CurrentUserId}, EncryptedFor: {EncryptedFor}", user.Id, model.Cipher.EncryptedFor);
|
||||
throw new BadRequestException("Cipher was not encrypted for the current user. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -218,6 +220,7 @@ public class CiphersController : Controller
|
||||
{
|
||||
if (model.Cipher.EncryptedFor != userId)
|
||||
{
|
||||
_logger.LogError("Cipher was not encrypted for the current user. CurrentUser: {CurrentUserId}, EncryptedFor: {EncryptedFor}", userId, model.Cipher.EncryptedFor);
|
||||
throw new BadRequestException("Cipher was not encrypted for the current user. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -244,6 +247,7 @@ public class CiphersController : Controller
|
||||
{
|
||||
if (model.EncryptedFor != user.Id)
|
||||
{
|
||||
_logger.LogError("Cipher was not encrypted for the current user. CipherId: {CipherId}, CurrentUser: {CurrentUserId}, EncryptedFor: {EncryptedFor}", id, user.Id, model.EncryptedFor);
|
||||
throw new BadRequestException("Cipher was not encrypted for the current user. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -281,6 +285,7 @@ public class CiphersController : Controller
|
||||
{
|
||||
if (model.EncryptedFor != userId)
|
||||
{
|
||||
_logger.LogError("Cipher was not encrypted for the current user. CipherId: {CipherId}, CurrentUser: {CurrentUserId}, EncryptedFor: {EncryptedFor}", id, userId, model.EncryptedFor);
|
||||
throw new BadRequestException("Cipher was not encrypted for the current user. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -706,6 +711,7 @@ public class CiphersController : Controller
|
||||
{
|
||||
if (model.Cipher.EncryptedFor != user.Id)
|
||||
{
|
||||
_logger.LogError("Cipher was not encrypted for the current user. CipherId: {CipherId} CurrentUser: {CurrentUserId}, EncryptedFor: {EncryptedFor}", id, user.Id, model.Cipher.EncryptedFor);
|
||||
throw new BadRequestException("Cipher was not encrypted for the current user. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -1077,6 +1083,7 @@ public class CiphersController : Controller
|
||||
{
|
||||
if (cipher.EncryptedFor.HasValue && cipher.EncryptedFor.Value != userId)
|
||||
{
|
||||
_logger.LogError("Cipher was not encrypted for the current user. CipherId: {CipherId}, CurrentUser: {CurrentUserId}, EncryptedFor: {EncryptedFor}", cipher.Id, userId, cipher.EncryptedFor);
|
||||
throw new BadRequestException("Cipher was not encrypted for the current user. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user