feat(backend): added auth, reviews, users modules
also provided tests
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ninja import ModelSchema, Schema
|
||||
from pydantic import Field
|
||||
|
||||
from apps.users.models import User
|
||||
|
||||
|
||||
class LoginIn(Schema):
|
||||
username: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
max_length=150,
|
||||
description="Username of the account",
|
||||
)
|
||||
password: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
description="Account password",
|
||||
)
|
||||
|
||||
|
||||
class TokenPairOut(Schema):
|
||||
access: str = Field(
|
||||
...,
|
||||
description=(
|
||||
"Short-lived JWT access token (used in Authorization header)"
|
||||
),
|
||||
)
|
||||
refresh: str = Field(
|
||||
...,
|
||||
description=(
|
||||
"Long-lived JWT refresh token (used to obtain a new access token)"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class TokenRefreshIn(Schema):
|
||||
refresh: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
description="A valid, non-expired refresh token",
|
||||
)
|
||||
|
||||
|
||||
class TokenRefreshOut(Schema):
|
||||
access: str = Field(
|
||||
...,
|
||||
description="Newly issued JWT access token",
|
||||
)
|
||||
|
||||
|
||||
class MeOut(ModelSchema):
|
||||
class Meta:
|
||||
model = User
|
||||
fields: ClassVar[tuple[str, ...]] = (
|
||||
User.id.field.name,
|
||||
User.username.field.name,
|
||||
User.email.field.name,
|
||||
User.role.field.name,
|
||||
User.first_name.field.name,
|
||||
User.last_name.field.name,
|
||||
User.is_active.field.name,
|
||||
)
|
||||
Reference in New Issue
Block a user