1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-21 20:44:18 +00:00

durante i test abbiamo notato che gli utenti non venivano eliminati ed avevamo una eccezione. Abbiamo modificato la cancellazione chiamando il metodo() delete invece di remove()

This commit is contained in:
stefanogoldoni 2021-04-28 00:40:46 +02:00
parent 6d62532a51
commit c708e6bfff

View file

@ -17,11 +17,12 @@ def page_user_delete():
user = find_user(get_jwt_identity())
if not user.isAdmin:
return json_error("User is not admin."), 403
target = find_user(request.json.get('email'))
deluser=request.json.get('email')
target = find_user(deluser)
if not target:
return json_error("User not found."), 404
if user == target:
return json_error("The user cant delete himself. Its a sin."), 406
Base.session.remove(target)
Base.session.delete(target)
Base.session.commit()
return json_success("The user has been deleted.")