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
351da5d4
Commit
351da5d4
authored
1 year ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Fix admin delete user in AdminUserList.js
parent
27fe4a95
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/static/js/ResourceLists/AdminUserList.js
+1
-2
1 addition, 2 deletions
app/static/js/ResourceLists/AdminUserList.js
app/users/json_routes.py
+22
-22
22 additions, 22 deletions
app/users/json_routes.py
with
23 additions
and
24 deletions
app/static/js/ResourceLists/AdminUserList.js
+
1
−
2
View file @
351da5d4
...
@@ -91,8 +91,7 @@ class AdminUserList extends ResourceList {
...
@@ -91,8 +91,7 @@ class AdminUserList extends ResourceList {
let
listAction
=
listActionElement
===
null
?
'
view
'
:
listActionElement
.
dataset
.
listAction
;
let
listAction
=
listActionElement
===
null
?
'
view
'
:
listActionElement
.
dataset
.
listAction
;
switch
(
listAction
)
{
switch
(
listAction
)
{
case
'
delete
'
:
{
case
'
delete
'
:
{
console
.
log
(
'
delete
'
,
itemId
);
Requests
.
users
.
entity
.
delete
(
itemId
);
Utils
.
deleteUserRequest
(
itemId
);
if
(
itemId
===
currentUserId
)
{
window
.
location
.
href
=
'
/
'
;}
if
(
itemId
===
currentUserId
)
{
window
.
location
.
href
=
'
/
'
;}
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
app/users/json_routes.py
+
22
−
22
View file @
351da5d4
...
@@ -7,29 +7,29 @@ from app.models import Avatar, User
...
@@ -7,29 +7,29 @@ from app.models import Avatar, User
from
.
import
bp
from
.
import
bp
#
@bp.route('/<hashid:user_id>', methods=['DELETE'])
@bp.route
(
'
/<hashid:user_id>
'
,
methods
=
[
'
DELETE
'
])
#
@content_negotiation(produces='application/json')
@content_negotiation
(
produces
=
'
application/json
'
)
#
def delete_user(user_id):
def
delete_user
(
user_id
):
#
def _delete_user(app, user_id):
def
_delete_user
(
app
,
user_id
):
#
with app.app_context():
with
app
.
app_context
():
#
user = User.query.get(user_id)
user
=
User
.
query
.
get
(
user_id
)
#
user.delete()
user
.
delete
()
#
db.session.commit()
db
.
session
.
commit
()
#
user = User.query.get_or_404(user_id)
user
=
User
.
query
.
get_or_404
(
user_id
)
#
if not (user == current_user or current_user.is_administrator()):
if
not
(
user
==
current_user
or
current_user
.
is_administrator
()):
#
abort(403)
abort
(
403
)
#
thread = Thread(
thread
=
Thread
(
#
target=_delete_user,
target
=
_delete_user
,
#
args=(current_app._get_current_object(), user.id)
args
=
(
current_app
.
_get_current_object
(),
user
.
id
)
#
)
)
#
if user == current_user:
if
user
==
current_user
:
#
logout_user()
logout_user
()
#
thread.start()
thread
.
start
()
#
response_data = {
response_data
=
{
#
'message': f'User "{user.username}" marked for deletion'
'
message
'
:
f
'
User
"
{
user
.
username
}
"
marked for deletion
'
#
}
}
#
return response_data, 202
return
response_data
,
202
# @bp.route('/<hashid:user_id>/avatar', methods=['DELETE'])
# @bp.route('/<hashid:user_id>/avatar', methods=['DELETE'])
...
...
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