maxkb/apps/users/views/login.py

40 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding=utf-8
"""
@project: MaxKB
@Author虎虎
@file user.py
@date2025/4/14 10:22
@desc:
"""
from django.utils.translation import gettext_lazy as _
from drf_spectacular.utils import extend_schema
from rest_framework.request import Request
from rest_framework.views import APIView
from common import result
from users.api.login import LoginAPI, CaptchaAPI
from users.serializers.login import LoginSerializer, CaptchaSerializer
class LoginView(APIView):
@extend_schema(methods=['POST'],
description=_("Log in"),
summary=_("Log in"),
operation_id=_("Log in"), # type: ignore
tags=[_("User management")], # type: ignore
request=LoginAPI.get_request(),
responses=LoginAPI.get_response())
def post(self, request: Request):
return result.success(LoginSerializer().login(request.data))
class CaptchaView(APIView):
@extend_schema(methods=['GET'],
summary=_("Get captcha"),
description=_("Get captcha"),
operation_id=_("Get captcha"), # type: ignore
tags=[_("User management")], # type: ignore
responses=CaptchaAPI.get_response())
def get(self, request: Request):
return result.success(CaptchaSerializer().generate())