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

[Gateway] #23 Changed authentication and response codes

parent a797866f
...@@ -71,7 +71,7 @@ paths: ...@@ -71,7 +71,7 @@ paths:
required: true required: true
type: "string" type: "string"
responses: responses:
'200': '204':
description: "Deletion succeeded" description: "Deletion succeeded"
'400': '400':
description: "User does not exist" description: "User does not exist"
...@@ -115,7 +115,7 @@ paths: ...@@ -115,7 +115,7 @@ paths:
type: string type: string
example: "secure_passw0rd" example: "secure_passw0rd"
responses: responses:
'200': '201':
description: "User was added to the database" description: "User was added to the database"
'400': '400':
description: "User already exists" description: "User already exists"
......
...@@ -12,7 +12,6 @@ produces: ...@@ -12,7 +12,6 @@ produces:
basePath: "/api" basePath: "/api"
# Paths supported by the server application # Paths supported by the server application
paths: paths:
/tokens/{token}: /tokens/{token}:
...@@ -67,7 +66,7 @@ paths: ...@@ -67,7 +66,7 @@ paths:
required: true required: true
type: "string" type: "string"
responses: responses:
'200': '204':
description: "Deletion succeeded" description: "Deletion succeeded"
'400': '400':
description: "User does not exist" description: "User does not exist"
...@@ -107,7 +106,7 @@ paths: ...@@ -107,7 +106,7 @@ paths:
type: string type: string
example: "secure_passw0rd" example: "secure_passw0rd"
responses: responses:
'200': '201':
description: "User was added to the database" description: "User was added to the database"
'400': '400':
description: "User already exists" description: "User already exists"
......
...@@ -50,7 +50,7 @@ def delete(username): ...@@ -50,7 +50,7 @@ def delete(username):
try: try:
UserService.delete(username) UserService.delete(username)
return Response(status = 200) return Response(status = 204)
except ValueError as e: except ValueError as e:
# return 400 if the user already exists # return 400 if the user already exists
return Response(status = 400, response=str(e)) return Response(status = 400, response=str(e))
...@@ -62,18 +62,17 @@ def add(): ...@@ -62,18 +62,17 @@ def add():
''' '''
data = request.json data = request.json
# overwrite possibly existing role with "regular user" # default role is "regular user"
if not 'role' in data:
data["role"] = "u" data["role"] = "u"
username = data["username"] try:
UserService.add(data["username"], data["password"], data["role"])
try :
UserService.add(username, data["password"], data["role"])
except ValueError as e: except ValueError as e:
# return 400 if the user already exists # return 400 if the user already exists
return Response(status = 400, response=str(e)) return Response(status = 400, response=str(e))
return Response(status=200) return Response(status=201)
def all(): 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