Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
naifu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
naifu
Commits
20678a44
Commit
20678a44
authored
Nov 01, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error message
parent
da9cb973
Pipeline
#17668
passed with stages
in 49 minutes and 25 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
main.py
main.py
+9
-3
No files found.
main.py
View file @
20678a44
...
...
@@ -58,7 +58,7 @@ def verify_token(req: Request):
if
"Authorization"
not
in
req
.
headers
:
raise
HTTPException
(
status_code
=
401
,
detail
=
"
Unauthorized
"
detail
=
"
Authorization header not present
"
)
token
=
req
.
headers
[
"Authorization"
]
if
token
.
startswith
(
"Bearer "
):
...
...
@@ -68,14 +68,20 @@ def verify_token(req: Request):
if
TOKEN_SERVER
:
tokenAuthResult
=
requests
.
get
(
TOKEN_SERVER
,
headers
=
{
"Authorization"
:
"Bearer "
+
token
})
if
tokenAuthResult
.
status_code
>=
400
:
tokenError
=
tokenAuthResult
.
json
()
errorMessage
=
'Unknown error'
for
key
in
[
'error'
,
'message'
,
'detail'
]:
if
key
in
tokenError
:
errorMessage
=
tokenError
[
key
]
break
raise
HTTPException
(
status_code
=
tokenAuthResult
.
status_code
,
detail
=
"Unauthorized"
detail
=
tokenError
[
'message'
]
)
return
True
raise
HTTPException
(
status_code
=
401
,
detail
=
"
Unauthorized
"
detail
=
"
Invalid token
"
)
#Initialize fastapi
app
=
FastAPI
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment