Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
595bda98
Commit
595bda98
authored
1 year ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Fix wrong admin check
parent
91e42d6d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/users/events.py
+32
-22
32 additions, 22 deletions
app/users/events.py
with
32 additions
and
22 deletions
app/users/events.py
+
32
−
22
View file @
595bda98
...
...
@@ -12,7 +12,7 @@ def get_user(user_hashid, backrefs=False, relationships=False):
user
=
User
.
query
.
get
(
user_id
)
if
user
is
None
:
return
{
'
status
'
:
404
,
'
statusText
'
:
'
Not found
'
}
if
not
(
user
==
current_user
or
current_user
.
is_administrator
):
if
not
(
user
==
current_user
or
current_user
.
is_administrator
()
):
return
{
'
status
'
:
403
,
'
statusText
'
:
'
Forbidden
'
}
return
{
'
body
'
:
user
.
to_json_serializeable
(
...
...
@@ -24,25 +24,6 @@ def get_user(user_hashid, backrefs=False, relationships=False):
}
# @socketio.on('GET /users/<user_id>')
# @socketio_login_required
# def get_user(user_hashid):
# user_id = hashids.decode(user_hashid)
# user = User.query.get(user_id)
# if user is None:
# return {'options': {'status': 404, 'statusText': 'Not found'}}
# if not (user == current_user or current_user.is_administrator):
# return {'options': {'status': 403, 'statusText': 'Forbidden'}}
# return {
# 'body': user.to_json_serializable2(),
# 'options': {
# 'status': 200,
# 'statusText': 'OK',
# 'headers': {'Content-Type: application/json'}
# }
# }
@socketio.on
(
'
SUBSCRIBE /users/<user_id>
'
)
@socketio_login_required
def
subscribe_user
(
user_hashid
):
...
...
@@ -50,7 +31,7 @@ def subscribe_user(user_hashid):
user
=
User
.
query
.
get
(
user_id
)
if
user
is
None
:
return
{
'
status
'
:
404
,
'
statusText
'
:
'
Not found
'
}
if
not
(
user
==
current_user
or
current_user
.
is_administrator
):
if
not
(
user
==
current_user
or
current_user
.
is_administrator
()
):
return
{
'
status
'
:
403
,
'
statusText
'
:
'
Forbidden
'
}
join_room
(
f
'
/users/
{
user
.
hashid
}
'
)
return
{
'
status
'
:
200
,
'
statusText
'
:
'
OK
'
}
...
...
@@ -63,7 +44,36 @@ def unsubscribe_user(user_hashid):
user
=
User
.
query
.
get
(
user_id
)
if
user
is
None
:
return
{
'
status
'
:
404
,
'
statusText
'
:
'
Not found
'
}
if
not
(
user
==
current_user
or
current_user
.
is_administrator
):
if
not
(
user
==
current_user
or
current_user
.
is_administrator
()
):
return
{
'
status
'
:
403
,
'
statusText
'
:
'
Forbidden
'
}
leave_room
(
f
'
/users/
{
user
.
hashid
}
'
)
return
{
'
status
'
:
200
,
'
statusText
'
:
'
OK
'
}
# @socketio.on('GET User')
# @socketio_login_required
# def n_get_user(user_hashid):
# # This constructs a JSON response which can easily be converted to a Response object
# # Ref: https://developer.mozilla.org/en-US/docs/Web/API/Response/Response
# user_id = hashids.decode(user_hashid)
# user = User.query.get(user_id)
# if user is None:
# return {'options': {'status': 404, 'statusText': 'Not found'}}
# if not (user == current_user or current_user.is_administrator()):
# return {'options': {'status': 403, 'statusText': 'Forbidden'}}
# body = {
# 'id': user.hashid,
# # ...
# 'relationships': {
# 'corpora': {corpus.hashid for corpus in user.corpora},
# 'jobs': [job.hashid for job in user.jobs]
# }
# }
# return {
# 'body': user.to_json_serializable(),
# 'options': {
# 'status': 200,
# 'statusText': 'OK',
# 'headers': {'Content-Type: application/json'}
# }
# }
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