mirror of
https://github.com/bitwarden/server.git
synced 2025-05-20 19:14:32 -05:00
suppress logs for bad security token
This commit is contained in:
parent
825295d0d3
commit
e7a7b946be
@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace Bit.Api.Utilities
|
||||
{
|
||||
@ -46,11 +47,15 @@ namespace Bit.Api.Utilities
|
||||
errorModel.Message = "Resource not found.";
|
||||
context.HttpContext.Response.StatusCode = 404;
|
||||
}
|
||||
else if(exception is SecurityTokenValidationException)
|
||||
{
|
||||
errorModel.Message = "Invalid token.";
|
||||
context.HttpContext.Response.StatusCode = 403;
|
||||
}
|
||||
else
|
||||
{
|
||||
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<ExceptionHandlerFilterAttribute>>();
|
||||
logger.LogError(0, exception, exception.Message);
|
||||
logger.LogError(0, exception, exception.Message);
|
||||
|
||||
errorModel.Message = "An unhandled server error has occured.";
|
||||
context.HttpContext.Response.StatusCode = 500;
|
||||
|
Loading…
x
Reference in New Issue
Block a user