| | |
| | | "/miniapp", |
| | | "/miniapp/login", |
| | | ) or request.path.startswith("/static") |
| | | |
| | | # Для API запросов возвращаем JSON вместо редиректа |
| | | is_api = request.path.startswith("/api/") |
| | | |
| | | if request["user"] is None and not public: |
| | | if is_api: |
| | | return web.json_response({"ok": False, "msg": "Не авторизован."}, status=401) |
| | | raise web.HTTPFound("/login") |
| | | try: |
| | | response = await handler(request) |
| | |
| | | token, |
| | | max_age=SESS_TTL, |
| | | httponly=True, |
| | | samesite="Lax", |
| | | secure=base_url(request).startswith("https"), |
| | | samesite="None", |
| | | secure=True, |
| | | ) |
| | | return resp |
| | | |