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
cbeaf1a9
Commit
cbeaf1a9
authored
Jul 15, 2024
by
deepdey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add expiry for login info
parent
c2eab1a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
15 deletions
+28
-15
app/routes/user/user_util.py
app/routes/user/user_util.py
+28
-15
No files found.
app/routes/user/user_util.py
View file @
cbeaf1a9
...
@@ -3,27 +3,40 @@ from app import orm as ORM
...
@@ -3,27 +3,40 @@ from app import orm as ORM
from
app.utils.redis
import
set_value
from
app.utils.redis
import
set_value
from
app
import
db
from
app
import
db
def
process_valid_loging
(
user_info
:
ORM
.
User
,
api_key
:
str
)
->
None
:
def
process_valid_loging
(
user_info
:
ORM
.
User
,
api_key
:
str
)
->
None
:
set_value
(
f
'{user_info.id}_un'
,
user_info
.
username
)
set_value
(
f
'{user_info.id}_un'
,
user_info
.
username
,
60
*
60
*
24
)
set_value
(
f
'{api_key}_id'
,
user_info
.
id
)
set_value
(
f
'{api_key}_id'
,
user_info
.
id
,
60
*
60
*
24
)
# TODO: currently we consider user have only one role
# TODO: currently we consider user have only one role
if
(
len
(
user_info
.
user_roles
)
>
0
):
if
len
(
user_info
.
user_roles
)
>
0
:
set_value
(
f
'{api_key}_rid'
,
user_info
.
user_roles
[
0
]
.
role
.
id
)
set_value
(
f
'{api_key}_rid'
,
user_info
.
user_roles
[
0
]
.
role
.
id
,
60
*
60
*
24
)
set_value
(
f
'{user_info.id}_rn'
,
user_info
.
user_roles
[
0
]
.
role
.
role_name
)
set_value
(
set_value
(
f
'{user_info.id}_rt'
,
user_info
.
user_roles
[
0
]
.
role
.
role_type
.
role_name
)
f
'{user_info.id}_rn'
,
user_info
.
user_roles
[
0
]
.
role
.
role_name
,
60
*
60
*
24
,
)
set_value
(
f
'{user_info.id}_rt'
,
user_info
.
user_roles
[
0
]
.
role
.
role_type
.
role_name
,
60
*
60
*
24
,
)
# TODO: fetch all api mapped with role id and set in redis
# TODO: fetch all api mapped with role id and set in redis
api_list
:
List
[
ORM
.
Api
]
=
db
.
session
.
query
(
ORM
.
Api
)
.
join
(
api_list
:
List
[
ORM
.
Api
]
=
(
ORM
.
RoleApiMap
,
db
.
session
.
query
(
ORM
.
Api
)
ORM
.
Api
.
id
==
ORM
.
RoleApiMap
.
api_id
.
join
(
ORM
.
RoleApiMap
,
ORM
.
Api
.
id
==
ORM
.
RoleApiMap
.
api_id
)
)
\
.
filter
(
.
filter
(
ORM
.
RoleApiMap
.
role_id
==
user_info
.
user_roles
[
0
]
.
role
.
id
,
ORM
.
RoleApiMap
.
role_id
==
user_info
.
user_roles
[
0
]
.
role
.
id
,
ORM
.
Api
.
tag
==
'RA'
ORM
.
Api
.
tag
==
'RA'
,
)
\
)
.
all
()
.
all
()
)
for
api
in
api_list
:
for
api
in
api_list
:
set_value
(
f
'r_{user_info.user_roles[0].role.id}_{api.id}_{api.method}'
,
1
)
set_value
(
\ No newline at end of file
f
'r_{user_info.user_roles[0].role.id}_{api.id}_{api.method}'
,
1
,
60
*
60
*
24
,
)
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