Added get_object method to verify if the user is the owner of the ssh key
This commit is contained in:
parent
824749545c
commit
c6b23f6aa0
1 changed files with 7 additions and 0 deletions
|
@ -342,6 +342,13 @@ class SSHKeyDeleteView(LoginRequiredMixin, DeleteView):
|
||||||
success_url = reverse_lazy('hosting:ssh_keys')
|
success_url = reverse_lazy('hosting:ssh_keys')
|
||||||
model = UserHostingKey
|
model = UserHostingKey
|
||||||
|
|
||||||
|
def get_object(self, queryset=None):
|
||||||
|
""" Hook to ensure object is owned by request.user. """
|
||||||
|
obj = super(SSHKeyDeleteView, self).get_object()
|
||||||
|
if not obj.owner == self.request.user:
|
||||||
|
raise Http404
|
||||||
|
return obj
|
||||||
|
|
||||||
def delete(self, request, *args, **kwargs):
|
def delete(self, request, *args, **kwargs):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager()
|
manager = OpenNebulaManager()
|
||||||
|
|
Loading…
Reference in a new issue