Skip to content
Snippets Groups Projects
Commit 9467c96f authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Fix: Changed Statuscode on invalid authorization

parent 3daf071a
No related branches found
No related tags found
2 merge requests!65Sprint/2021 08,!64Change Statuscode
using Coscine.Configuration;
using Coscine.Configuration;
using Coscine.JwtHandler;
using Coscine.Logging;
using Microsoft.AspNetCore.Http;
......@@ -63,7 +63,7 @@ namespace Coscine.ApiCommons.Middleware
// Get the User Id
var authorization = context.Request.Headers["Authorization"].ToArray();
string bearer = null;
foreach (var line in authorization)
foreach (var line in authorization)
{
if (line.Contains("Bearer"))
{
......@@ -180,8 +180,8 @@ namespace Coscine.ApiCommons.Middleware
if (!context.Response.HasStarted)
{
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
byte[] data = System.Text.Encoding.UTF8.GetBytes("Unhandled Error occured. Please, try again in a while.");
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
byte[] data = System.Text.Encoding.UTF8.GetBytes("Invalid authentication. Please try again.");
context.Response.ContentLength = data.Length;
originalResponseBody.Write(data, 0, data.Length);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment