51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Debug login issue.
|
|
"""
|
|
|
|
import re
|
|
|
|
import httpx
|
|
|
|
BASE_URL = "http://localhost:8000"
|
|
|
|
|
|
def main():
|
|
print("Debugging login issue...")
|
|
|
|
with httpx.Client(base_url=BASE_URL, timeout=30.0) as client:
|
|
# Get login page
|
|
response = client.get("/admin/login")
|
|
print(f"Login page status: {response.status_code}")
|
|
|
|
# Extract CSRF token
|
|
match = re.search(r'name="csrf_token" value="([^"]+)"', response.text)
|
|
csrf_token = match.group(1) if match else ""
|
|
print(f"CSRF token: {csrf_token[:30]}...")
|
|
|
|
# Look for any error messages in the page
|
|
if "error" in response.text.lower():
|
|
print("\n=== Error messages in login page ===")
|
|
# Extract error div content
|
|
error_match = re.search(
|
|
r'<div class="error">(.*?)</div>', response.text, re.DOTALL
|
|
)
|
|
if error_match:
|
|
print(error_match.group(1))
|
|
else:
|
|
# Print a portion of the page around "error"
|
|
idx = response.text.lower().find("error")
|
|
print(response.text[max(0, idx - 50) : idx + 200])
|
|
|
|
# Try to check if Redis is accessible via the health endpoint
|
|
health = client.get("/health")
|
|
print(f"\nHealth check: {health.text}")
|
|
|
|
# Print login page content for inspection
|
|
print("\n=== Login page content (first 2000 chars) ===")
|
|
print(response.text[:2000])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|