mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-11 12:19:41 +00:00
feat: 添加 临时 password (#8035)
* perf: 添加 template password * perf: 修改id * perf: 修改 翻译 * perf: 修改 tmp token * perf: 修改 token Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
@@ -11,3 +11,4 @@ from .wecom import *
|
||||
from .dingtalk import *
|
||||
from .feishu import *
|
||||
from .password import *
|
||||
from .temp_token import *
|
||||
|
27
apps/authentication/api/temp_token.py
Normal file
27
apps/authentication/api/temp_token.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from django.utils import timezone
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
|
||||
from common.drf.api import JMSModelViewSet
|
||||
from common.permissions import IsValidUser
|
||||
from ..models import TempToken
|
||||
from ..serializers import TempTokenSerializer
|
||||
|
||||
|
||||
class TempTokenViewSet(JMSModelViewSet):
|
||||
serializer_class = TempTokenSerializer
|
||||
permission_classes = [IsValidUser]
|
||||
http_method_names = ['post', 'get', 'options', 'patch']
|
||||
|
||||
def get_queryset(self):
|
||||
username = self.request.user.username
|
||||
return TempToken.objects.filter(username=username)
|
||||
|
||||
@action(methods=['PATCH'], detail=True, url_path='expire')
|
||||
def expire(self, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
instance.date_expired = timezone.now()
|
||||
instance.save()
|
||||
serializer = self.get_serializer(instance)
|
||||
return Response(serializer.data)
|
||||
|
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
from django.shortcuts import redirect
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.generics import CreateAPIView
|
||||
|
Reference in New Issue
Block a user