mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-05 23:54:19 +00:00
Hotfix: user and ssh key creation when no were defined
This commit is contained in:
parent
1432671cbe
commit
e00aaf7118
|
@ -97,6 +97,8 @@ class WriteSSHKey(Resource):
|
|||
data = json.load(userdata_file)
|
||||
if "ssh" not in data:
|
||||
data["ssh"] = {}
|
||||
if "rootKeys" not in data["ssh"]:
|
||||
data["ssh"]["rootKeys"] = []
|
||||
# Return 409 if key already in array
|
||||
for key in data["ssh"]["rootKeys"]:
|
||||
if key == public_key:
|
||||
|
|
|
@ -104,13 +104,14 @@ class Users(Resource):
|
|||
try:
|
||||
data = json.load(userdata_file)
|
||||
|
||||
if "users" not in data:
|
||||
data["users"] = []
|
||||
|
||||
# Return 400 if user already exists
|
||||
for user in data["users"]:
|
||||
if user["username"] == args["username"]:
|
||||
return {"error": "User already exists"}, 409
|
||||
|
||||
if "users" not in data:
|
||||
data["users"] = []
|
||||
data["users"].append(
|
||||
{
|
||||
"username": args["username"],
|
||||
|
|
Loading…
Reference in a new issue