Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApiCommons
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
libraries
ApiCommons
Commits
9467c96f
Commit
9467c96f
authored
4 years ago
by
Petar Hristov
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Changed Statuscode on invalid authorization
parent
3daf071a
No related branches found
No related tags found
2 merge requests
!65
Sprint/2021 08
,
!64
Change Statuscode
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ApiCommons/Middleware/LoggingMiddleware.cs
+4
-4
4 additions, 4 deletions
src/ApiCommons/Middleware/LoggingMiddleware.cs
with
4 additions
and
4 deletions
src/ApiCommons/Middleware/LoggingMiddleware.cs
+
4
−
4
View file @
9467c96f
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
.
Status
500InternalServerError
;
byte
[]
data
=
System
.
Text
.
Encoding
.
UTF8
.
GetBytes
(
"
Unhandled Error occured
. Please
,
try again
in a while
."
);
context
.
Response
.
StatusCode
=
StatusCodes
.
Status
401Unauthorized
;
byte
[]
data
=
System
.
Text
.
Encoding
.
UTF8
.
GetBytes
(
"
Invalid authentication
. Please try again."
);
context
.
Response
.
ContentLength
=
data
.
Length
;
originalResponseBody
.
Write
(
data
,
0
,
data
.
Length
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment