2026-05-14 20:01:26 +08:00
|
|
|
"""Authentication API routes."""
|
|
|
|
|
|
|
|
|
|
from fastapi import APIRouter, Request
|
|
|
|
|
|
2026-05-29 19:24:46 +08:00
|
|
|
from web.core import ReferralApplyRequest, TelegramBindTokenRequest, TelegramLoginRequest
|
2026-05-18 17:10:44 +08:00
|
|
|
from web.services.auth_api import (
|
2026-05-29 19:24:46 +08:00
|
|
|
apply_referral_code,
|
2026-05-18 17:10:44 +08:00
|
|
|
bind_telegram_by_token,
|
2026-05-19 18:07:39 +08:00
|
|
|
create_telegram_bot_bind_link,
|
2026-05-18 17:10:44 +08:00
|
|
|
get_auth_me_payload,
|
|
|
|
|
login_with_telegram,
|
|
|
|
|
)
|
2026-05-14 20:01:26 +08:00
|
|
|
|
|
|
|
|
router = APIRouter(tags=["auth"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/api/auth/me")
|
|
|
|
|
async def auth_me(request: Request):
|
|
|
|
|
return get_auth_me_payload(request)
|
2026-05-18 16:18:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/api/auth/telegram/login")
|
|
|
|
|
async def auth_telegram_login(request: Request, body: TelegramLoginRequest):
|
|
|
|
|
return login_with_telegram(request, body)
|
2026-05-18 17:10:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/api/auth/telegram/bind-by-token")
|
|
|
|
|
async def auth_telegram_bind_by_token(request: Request, body: TelegramBindTokenRequest):
|
|
|
|
|
return bind_telegram_by_token(request, body)
|
2026-05-19 18:07:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/api/auth/telegram/bot-bind-link")
|
|
|
|
|
async def auth_telegram_bot_bind_link(request: Request):
|
|
|
|
|
return create_telegram_bot_bind_link(request)
|
2026-05-29 19:24:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/api/auth/referral/apply")
|
|
|
|
|
async def auth_referral_apply(request: Request, body: ReferralApplyRequest):
|
|
|
|
|
return apply_referral_code(request, body)
|