Commit 0e54c2a6 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Hide deleted ssh_keys

parent ad64e218
......@@ -70,7 +70,10 @@ class SSHPublicKeyView(views.APIView):
key = get_object_or_404(
# we do not delete ssh keys directly, as we need to keep track
# of them until all clients have also deleted them
key.deleted = True
return redirect('/backend/api/state/')
elif request_type == 'add':
if 'key' in
......@@ -24,6 +24,12 @@ class User(AbstractUser):
sub = models.CharField(max_length=150, blank=True, null=True)
password = models.CharField(max_length=150, blank=True, null=True)
# we hide deleted keys here
# the full list of ssh keys is at self._ssh_keys
def ssh_keys(self):
return self._ssh_keys.filter(deleted=False)
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
......@@ -165,9 +171,10 @@ class Service(models.Model):
class SSHPublicKey(models.Model):
name = models.CharField(max_length=150, unique=True)
key = models.TextField(max_length=1000)
# hidden field at the user
user = models.ForeignKey(
# at which sites is this ssh key deployed?
deployements = models.ManyToManyField(
......@@ -183,6 +190,8 @@ class SSHPublicKey(models.Model):
def __str__(self):
if self.deleted:
return "DELETED: {}".format(
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