mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-22 08:19:04 +00:00
fix: 连接令牌添加 expire_time 和 is_valid 字段
This commit is contained in:
committed by
Jiangjie.Bai
parent
cd119a2999
commit
b262643f0a
@@ -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()
|
||||
|
Reference in New Issue
Block a user