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
b23cf6d1
Commit
b23cf6d1
authored
Jul 21, 2024
by
deepdey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update get-user-logic
parent
0d503270
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
25 deletions
+7
-25
app/routes/user/user_dao_service.py
app/routes/user/user_dao_service.py
+7
-25
No files found.
app/routes/user/user_dao_service.py
View file @
b23cf6d1
...
...
@@ -21,18 +21,8 @@ def get_user_by_id_for_admin(admin_id: int, user_id: int) -> ORM.User | None:
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
PROJECT_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
raise
Exception
(
'You do not have permission to view user details'
)
else
:
# return all user data for project admin for his specific project
return
ORM
.
User
.
query
.
filter
(
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
,
ORM
.
User
.
id
==
user_id
,
ORM
.
User
.
project_id
==
admin_user
.
project_id
...
...
@@ -50,21 +40,13 @@ def get_user_list_for_project_admin(admin_id: int) -> List[ORM.User]:
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
PROJECT_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
raise
Exception
(
'You do not have permission to view user list'
)
else
:
# return all user data for project admin for his specific project
return
ORM
.
User
.
query
.
filter
(
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
,
ORM
.
User
.
project_id
==
admin_user
.
project_id
)
.
all
()
else
:
# return all user data for super admin
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
)
.
all
()
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
)
.
all
()
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