Commit c66fafaa authored by Lukas Burgey's avatar Lukas Burgey

Fix bug in ssh key view

parent 9cb91a6a
......@@ -80,23 +80,23 @@ class SSHPublicKeyView(views.APIView):
).data
)
elif 'key' in request.data:
elif 'key' in request.data and 'name' in request.data:
key_name = request.data['key']
key_data = request.data['key']
if 'key' in key_data and 'name' in key_data:
key = models.SSHPublicKey(
user=request.user,
name=key_data['name'],
key=key_data['key'],
)
key.save()
request.user.user_changed_key_added(key)
return Response(
serializers.SSHPublicKeySerializer(
key,
).data
)
key = models.SSHPublicKey(
user=request.user,
name=key_name,
key=key_data,
)
key.save()
request.user.user_changed_key_added(key)
return Response(
serializers.SSHPublicKeySerializer(
key,
).data
)
LOGGER.error('SSHPublicKeyView: malformed request %s', request.data)
return _api_error_response("malformed request")
......
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