Commit 2d3a37b4 authored by ibuler's avatar ibuler

Merge branch 'dev_beta' of github.com:jumpserver/jumpserver into dev_beta

parents 2693d68e 8074e669
...@@ -112,6 +112,7 @@ def on_node_assets_changed(sender, instance=None, **kwargs): ...@@ -112,6 +112,7 @@ def on_node_assets_changed(sender, instance=None, **kwargs):
@receiver(post_save, sender=Node) @receiver(post_save, sender=Node)
def on_node_update_or_created(sender, instance=None, created=False, **kwargs): def on_node_update_or_created(sender, instance=None, created=False, **kwargs):
if instance and not created: if instance and not created:
Asset.expire_all_nodes_keys_cache()
instance.expire_full_value() instance.expire_full_value()
......
...@@ -207,20 +207,19 @@ class TokenMixin: ...@@ -207,20 +207,19 @@ class TokenMixin:
@property @property
def private_token(self): def private_token(self):
from authentication.models import PrivateToken return self.create_private_token()
try:
token = PrivateToken.objects.get(user=self)
except PrivateToken.DoesNotExist:
token = self.create_private_token()
return token
def create_private_token(self): def create_private_token(self):
from authentication.models import PrivateToken from authentication.models import PrivateToken
token = PrivateToken.objects.create(user=self) token, created = PrivateToken.objects.get_or_create(user=self)
return token return token
def delete_private_token(self):
from authentication.models import PrivateToken
PrivateToken.objects.filter(user=self).delete()
def refresh_private_token(self): def refresh_private_token(self):
self.private_token.delete() self.delete_private_token()
return self.create_private_token() return self.create_private_token()
def create_bearer_token(self, request=None): def create_bearer_token(self, request=None):
......
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