mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 06:24:19 +00:00
The hell was I thinking
This commit is contained in:
parent
46ed8416d1
commit
b0217d6f36
1 changed files with 2 additions and 1 deletions
|
@ -71,11 +71,12 @@ def page_users():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if not user.isAdmin:
|
if not user.isAdmin:
|
||||||
return json_error("User is not admin. Thou art not authorized."), 403
|
return json_error("User is not admin. Thou art not authorized."), 403
|
||||||
if not request.json.get("email") or request.json.get("password") or request.json.get("username"):
|
if not request.json.get("email") or not request.json.get("password") or not request.json.get("username"):
|
||||||
return json_error("Missing required fields."), 400
|
return json_error("Missing required fields."), 400
|
||||||
if User.query.filter_by(email=request.json.get("email")).first():
|
if User.query.filter_by(email=request.json.get("email")).first():
|
||||||
return json_error("User already exists."), 406
|
return json_error("User already exists."), 406
|
||||||
new_user = User(email=request.json.get("email"), password=gen_password(request.json.get("password")),
|
new_user = User(email=request.json.get("email"), password=gen_password(request.json.get("password")),
|
||||||
username=request.json.get("username"))
|
username=request.json.get("username"))
|
||||||
ext.session.add(new_user)
|
ext.session.add(new_user)
|
||||||
|
ext.session.commit()
|
||||||
return json_success(new_user.to_json()), 201
|
return json_success(new_user.to_json()), 201
|
||||||
|
|
Loading…
Reference in a new issue