mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-24 14:04:19 +00:00
parent
c4f7d65820
commit
1019a43832
2 changed files with 10 additions and 2 deletions
|
@ -17,7 +17,7 @@ def page_repositories():
|
|||
- jwt: []
|
||||
responses:
|
||||
'200':
|
||||
description: The list of the repositories related to the user (divided in "owner" and "spectator" dict keys), incapsulated in Success.
|
||||
description: The list of the repositories related to the user, incapsulated in Success.
|
||||
'403':
|
||||
description: The user is not authorized.
|
||||
content:
|
||||
|
|
|
@ -49,6 +49,11 @@ def page_users():
|
|||
content:
|
||||
application/json:
|
||||
schema: Error
|
||||
'406':
|
||||
description: The user already exists.
|
||||
content:
|
||||
application/json:
|
||||
schema: Error
|
||||
'401':
|
||||
description: The user is not logged in.
|
||||
content:
|
||||
|
@ -66,8 +71,11 @@ def page_users():
|
|||
if request.method == "POST":
|
||||
if not user.isAdmin:
|
||||
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"):
|
||||
return json_error("Missing required fields."), 400
|
||||
if User.query.filter_by(email=request.json.get("email")).first():
|
||||
return json_error("User already exists."), 406
|
||||
new_user = User(email=request.json.get("email"), password=gen_password(request.json.get("password")),
|
||||
username=request.json.get("username"))
|
||||
ext.session.add(new_user)
|
||||
ext.session.commit()
|
||||
return json_success(new_user.to_json()), 201
|
||||
|
|
Loading…
Reference in a new issue