mirror of https://github.com/jumpserver/jumpserver
perf: 同一个协作会话链接,限制同一用户仅可使用一次
parent
20c1f4a293
commit
440cd13fcc
|
@ -1,8 +1,8 @@
|
||||||
from rest_framework.exceptions import MethodNotAllowed, ValidationError
|
|
||||||
from rest_framework.decorators import action
|
|
||||||
from rest_framework.response import Response
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from rest_framework.exceptions import MethodNotAllowed, ValidationError
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from common.const.http import PATCH
|
from common.const.http import PATCH
|
||||||
from orgs.mixins.api import OrgModelViewSet
|
from orgs.mixins.api import OrgModelViewSet
|
||||||
|
|
|
@ -133,6 +133,13 @@ class SessionJoinRecord(JMSBaseModel, OrgModelMixin):
|
||||||
# self
|
# self
|
||||||
if self.verify_code != self.sharing.verify_code:
|
if self.verify_code != self.sharing.verify_code:
|
||||||
return False, _('Invalid verification code')
|
return False, _('Invalid verification code')
|
||||||
|
|
||||||
|
# Link can only be joined once by the same user.
|
||||||
|
queryset = SessionJoinRecord.objects.filter(
|
||||||
|
verify_code=self.verify_code, sharing=self.sharing,
|
||||||
|
joiner=self.joiner, date_joined__lt=self.date_joined)
|
||||||
|
if queryset.exists():
|
||||||
|
return False, _('You have already joined this session')
|
||||||
return True, ''
|
return True, ''
|
||||||
|
|
||||||
def join_failed(self, reason):
|
def join_failed(self, reason):
|
||||||
|
|
Loading…
Reference in New Issue