mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 22:44:19 +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:
parent
6d62532a51
commit
c708e6bfff
1 changed files with 3 additions and 2 deletions
|
@ -17,11 +17,12 @@ def page_user_delete():
|
||||||
user = find_user(get_jwt_identity())
|
user = find_user(get_jwt_identity())
|
||||||
if not user.isAdmin:
|
if not user.isAdmin:
|
||||||
return json_error("User is not admin."), 403
|
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:
|
if not target:
|
||||||
return json_error("User not found."), 404
|
return json_error("User not found."), 404
|
||||||
if user == target:
|
if user == target:
|
||||||
return json_error("The user cant delete himself. Its a sin."), 406
|
return json_error("The user cant delete himself. Its a sin."), 406
|
||||||
Base.session.remove(target)
|
Base.session.delete(target)
|
||||||
Base.session.commit()
|
Base.session.commit()
|
||||||
return json_success("The user has been deleted.")
|
return json_success("The user has been deleted.")
|
||||||
|
|
Loading…
Reference in a new issue