Commit 9c1ccb14 authored by Alexander Lercher's avatar Alexander Lercher

[Gateway] #23 Changed authentication and response codes

parent a797866f
......@@ -71,7 +71,7 @@ paths:
required: true
type: "string"
responses:
'200':
'204':
description: "Deletion succeeded"
'400':
description: "User does not exist"
......@@ -115,7 +115,7 @@ paths:
type: string
example: "secure_passw0rd"
responses:
'200':
'201':
description: "User was added to the database"
'400':
description: "User already exists"
......
......@@ -12,7 +12,6 @@ produces:
basePath: "/api"
# Paths supported by the server application
paths:
/tokens/{token}:
......@@ -67,7 +66,7 @@ paths:
required: true
type: "string"
responses:
'200':
'204':
description: "Deletion succeeded"
'400':
description: "User does not exist"
......@@ -107,7 +106,7 @@ paths:
type: string
example: "secure_passw0rd"
responses:
'200':
'201':
description: "User was added to the database"
'400':
description: "User already exists"
......
......@@ -50,7 +50,7 @@ def delete(username):
try:
UserService.delete(username)
return Response(status = 200)
return Response(status = 204)
except ValueError as e:
# return 400 if the user already exists
return Response(status = 400, response=str(e))
......@@ -62,18 +62,17 @@ def add():
'''
data = request.json
# overwrite possibly existing role with "regular user"
# default role is "regular user"
if not 'role' in data:
data["role"] = "u"
username = data["username"]
try :
UserService.add(username, data["password"], data["role"])
try:
UserService.add(data["username"], data["password"], data["role"])
except ValueError as e:
# return 400 if the user already exists
return Response(status = 400, response=str(e))
return Response(status=200)
return Response(status=201)
def all():
'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment