Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
9c1ccb14
Commit
9c1ccb14
authored
Sep 10, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Gateway]
#23
Changed authentication and response codes
parent
a797866f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
13 deletions
+11
-13
swagger.yml
src/rest-gateway/app/configs/swagger.yml
+2
-2
swagger_local.yml
src/rest-gateway/app/configs/swagger_local.yml
+2
-3
user.py
src/rest-gateway/app/routes/user.py
+7
-8
No files found.
src/rest-gateway/app/configs/swagger.yml
View file @
9c1ccb14
...
@@ -71,7 +71,7 @@ paths:
...
@@ -71,7 +71,7 @@ paths:
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
responses
:
responses
:
'
20
0
'
:
'
20
4
'
:
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
:
'
20
0
'
:
'
20
1
'
:
description
:
"
User
was
added
to
the
database"
description
:
"
User
was
added
to
the
database"
'
400'
:
'
400'
:
description
:
"
User
already
exists"
description
:
"
User
already
exists"
...
...
src/rest-gateway/app/configs/swagger_local.yml
View file @
9c1ccb14
...
@@ -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
:
'
20
0
'
:
'
20
4
'
:
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
:
'
20
0
'
:
'
20
1
'
:
description
:
"
User
was
added
to
the
database"
description
:
"
User
was
added
to
the
database"
'
400'
:
'
400'
:
description
:
"
User
already
exists"
description
:
"
User
already
exists"
...
...
src/rest-gateway/app/routes/user.py
View file @
9c1ccb14
...
@@ -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
=
20
0
)
return
Response
(
status
=
20
4
)
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"
data
[
"role"
]
=
"u"
if
not
'role'
in
data
:
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
=
20
0
)
return
Response
(
status
=
20
1
)
def
all
():
def
all
():
'''
'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment