fix: 连接令牌添加 expire_time 和 is_valid 字段

This commit is contained in:
Jiangjie.Bai
2022-07-12 18:27:07 +08:00
committed by Jiangjie.Bai
parent cd119a2999
commit b262643f0a
2 changed files with 12 additions and 2 deletions

View File

@@ -114,6 +114,14 @@ class ConnectionToken(OrgModelMixin, models.JMSModel):
def is_expired(self):
return self.date_expired < timezone.now()
@property
def expire_time(self):
interval = self.date_expired - timezone.now()
seconds = interval.total_seconds()
if seconds < 0:
seconds = 0
return int(seconds)
def expire(self):
self.date_expired = timezone.now()
self.save()