Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
webomagic-auth
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Pratik Shrivastava
webomagic-auth
Commits
c491f760
Commit
c491f760
authored
Jul 14, 2024
by
deepdey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update response config
parent
8ddf56d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
9 deletions
+11
-9
app/app_config/response_code.py
app/app_config/response_code.py
+2
-2
app/routes/user/__init__.py
app/routes/user/__init__.py
+0
-2
app/utils/api_response.py
app/utils/api_response.py
+3
-3
app/utils/redis.py
app/utils/redis.py
+6
-2
No files found.
app/app_config/response_code.py
View file @
c491f760
SUCCESS_CODE
:
int
=
20
0
VALIDATION_ERROR_CODE
:
int
=
40
3
SUCCESS_CODE
:
int
=
20
1
VALIDATION_ERROR_CODE
:
int
=
40
0
EXCEPTION_CODE
:
int
=
500
UN_AUTHORIZED_CODE
:
int
=
401
\ No newline at end of file
app/routes/user/__init__.py
View file @
c491f760
...
...
@@ -55,8 +55,6 @@ class Login(Resource):
if
not
bcrypt
.
check_password_hash
(
user_info
.
password
,
password
):
return
prepare_api_response
(
401
,
'Invalid password'
)
# fetch user role info
api_key
=
self
.
generate_api_key
()
process_valid_loging
(
user_info
,
api_key
)
...
...
app/utils/api_response.py
View file @
c491f760
...
...
@@ -9,7 +9,7 @@ def prepare_swagger_response(
data
:
any
=
None
)
->
dict
:
response
:
dict
=
{
'code'
:
fields
.
Integer
(
default
=
code
),
'
status_
code'
:
fields
.
Integer
(
default
=
code
),
'message'
:
fields
.
String
(
default
=
message
)
}
...
...
@@ -27,7 +27,7 @@ def prepare_api_response(
)
->
dict
:
response
:
dict
=
{
'code'
:
int
(
code
),
'
status_
code'
:
int
(
code
),
'message'
:
str
(
message
)
}
...
...
@@ -35,6 +35,6 @@ def prepare_api_response(
response
[
'data'
]
=
data
if
(
error
is
not
None
):
response
[
'error'
]
=
error
response
[
'error
s
'
]
=
error
return
response
,
code
app/utils/redis.py
View file @
c491f760
from
typing
import
Optional
import
redis
from
app.app_config.config
import
REDIS_HOST
,
REDIS_PORT
,
REDIS_DATABASE
...
...
@@ -21,10 +22,13 @@ def get_value(key: str) -> str | None:
return
None
def
set_value
(
key
:
str
,
value
:
str
)
->
bool
:
def
set_value
(
key
:
str
,
value
:
str
,
expire_time
:
Optional
[
int
]
=
None
)
->
bool
:
try
:
client
=
get_client
(
REDIS_HOST
,
REDIS_PORT
,
None
)
client
.
set
(
key
,
value
)
if
expire_time
:
client
.
set
(
key
,
value
,
ex
=
expire_time
)
else
:
client
.
set
(
key
,
value
)
return
True
except
Exception
as
e
:
print
(
e
)
...
...
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