Skip to content
Snippets Groups Projects
Commit 3b924e16 authored by Timothee Besset's avatar Timothee Besset
Browse files

use a json one liner dictionary with an 'error' key in more places

parent 4c2f6858
No related branches found
No related tags found
No related merge requests found
...@@ -258,14 +258,14 @@ class DevkitHandler(BaseHTTPRequestHandler): ...@@ -258,14 +258,14 @@ class DevkitHandler(BaseHTTPRequestHandler):
if not filename: if not filename:
self._send_headers(403, "text/plain") self._send_headers(403, "text/plain")
self.wfile.write(b"Failed to write ssh key\n") self.wfile.write(json.dumps({'error':'Failed to write the ssh key'}).encode())
return return
# Run approve script # Run approve script
approve_hook = find_hook("approve-ssh-key") approve_hook = find_hook("approve-ssh-key")
if not approve_hook: if not approve_hook:
self._send_headers(403, "text/plain") self._send_headers(403, "text/plain")
self.wfile.write(b"Failed to find approve hook\n") self.wfile.write(json.dumps({'error':'Failed to find approve hook'}).encode())
os.unlink(filename) os.unlink(filename)
return return
...@@ -282,8 +282,7 @@ class DevkitHandler(BaseHTTPRequestHandler): ...@@ -282,8 +282,7 @@ class DevkitHandler(BaseHTTPRequestHandler):
approve_object = json.loads(approve_output) approve_object = json.loads(approve_output)
if "error" in approve_object: if "error" in approve_object:
self._send_headers(403, "text/plain") self._send_headers(403, "text/plain")
self.wfile.write("approve-ssh-key:\n".encode()) self.wfile.write(approve_output.encode()) # is already a json {'error':} response
self.wfile.write(approve_output.encode())
os.unlink(filename) os.unlink(filename)
return return
...@@ -291,7 +290,7 @@ class DevkitHandler(BaseHTTPRequestHandler): ...@@ -291,7 +290,7 @@ class DevkitHandler(BaseHTTPRequestHandler):
install_hook = find_hook("install-ssh-key") install_hook = find_hook("install-ssh-key")
if not install_hook: if not install_hook:
self._send_headers(403, "text-plain") self._send_headers(403, "text-plain")
self.wfile.write(b"Failed to find install-ssh-key hook\n") self.wfile.write(json.dumps({'error':'Failed to find install-ssh-key hook'}).encode())
os.unlink(filename) os.unlink(filename)
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment