mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-06-02 11:55:25 +00:00
* perf: 优化mfa 和登录 * perf: stash * stash * pref: 基本完成 * perf: remove init function * perf: 优化命名 * perf: 优化backends * perf: 基本完成优化 * perf: 修复首页登录时没有 toastr 的问题 Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: Jiangjie.Bai <32935519+BaiJiangJie@users.noreply.github.com>
27 lines
945 B
Python
27 lines
945 B
Python
from rest_framework.generics import CreateAPIView
|
|
from rest_framework.response import Response
|
|
|
|
from authentication.serializers import PasswordVerifySerializer
|
|
from common.permissions import IsValidUser
|
|
from authentication.mixins import authenticate
|
|
from authentication.errors import PasswordInvalid
|
|
from authentication.mixins import AuthMixin
|
|
|
|
|
|
class UserPasswordVerifyApi(AuthMixin, CreateAPIView):
|
|
permission_classes = (IsValidUser,)
|
|
serializer_class = PasswordVerifySerializer
|
|
|
|
def create(self, request, *args, **kwargs):
|
|
serializer = self.get_serializer(data=request.data)
|
|
serializer.is_valid(raise_exception=True)
|
|
password = serializer.validated_data['password']
|
|
user = self.request.user
|
|
|
|
user = authenticate(request=request, username=user.username, password=password)
|
|
if not user:
|
|
raise PasswordInvalid
|
|
|
|
self.mark_password_ok(user)
|
|
return Response()
|