mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-01-15 20:14:27 +01:00
Fix exception occuring on Admin demotion (#1799)
* Fix an exception that occurred when demoting an Admin user * Fix the response from the above request from returning a list instead of a dict * Closes #1794
This commit is contained in:
@@ -233,16 +233,18 @@ class UserPublic(Resource):
|
||||
if response.errors:
|
||||
return {"success": False, "errors": response.errors}, 400
|
||||
|
||||
db.session.commit()
|
||||
|
||||
# This generates the response first before actually changing the type
|
||||
# This avoids an error during User type changes where we change
|
||||
# the polymorphic identity resulting in an ObjectDeletedError
|
||||
# https://github.com/CTFd/CTFd/issues/1794
|
||||
response = schema.dump(response.data)
|
||||
|
||||
db.session.commit()
|
||||
db.session.close()
|
||||
|
||||
clear_user_session(user_id=user_id)
|
||||
clear_standings()
|
||||
|
||||
return {"success": True, "data": response}
|
||||
return {"success": True, "data": response.data}
|
||||
|
||||
@admins_only
|
||||
@users_namespace.doc(
|
||||
|
||||
Reference in New Issue
Block a user