Dex error
This commit is contained in:
@@ -12,7 +12,7 @@ from authlib.integrations.django_client import OAuth
|
||||
from django.conf import settings
|
||||
from django.core.validators import validate_email
|
||||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
from django.db import ProgrammingError, transaction
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.db.models import Q
|
||||
@@ -213,6 +213,18 @@ def callback(request):
|
||||
expires_at = proof.get("expires_at") if isinstance(proof, dict) else None
|
||||
registration_account_id = proof.get("account_id") if isinstance(expires_at, (int, float)) and expires_at > timezone.now().timestamp() else None
|
||||
account = link_identity(token.get("userinfo") or {}, registration_account_id=registration_account_id)
|
||||
except ProgrammingError as exc:
|
||||
# PostgreSQL diagnostics and SQL text can contain identity data. Log
|
||||
# only a validated SQLSTATE, never the exception message or traceback.
|
||||
sqlstate = getattr(exc.__cause__, "sqlstate", None)
|
||||
sqlstate = sqlstate if isinstance(sqlstate, str) and re.fullmatch(r"[0-9A-Z]{5}", sqlstate) else "unknown"
|
||||
hint = {
|
||||
"42703": "undefined_column: check pending migrations, especially members.0004_dex_login_identity, against the web database",
|
||||
"42P01": "undefined_table: check migrations and the configured database/schema",
|
||||
"42501": "insufficient_privilege: check database role permissions",
|
||||
}.get(sqlstate, "check database schema, permissions and matching application/migration images")
|
||||
logger.error("Membership database failure during Dex callback kind=ProgrammingError sqlstate=%s; %s", sqlstate, hint)
|
||||
return page(request, title="Sign-in could not be verified", message="Try signing in again, or contact the administrator.")
|
||||
except Exception as exc:
|
||||
logger.error("Dex callback rejected kind=%s", type(exc).__name__)
|
||||
return page(request, title="Sign-in could not be verified", message="Try signing in again, or contact the administrator.")
|
||||
|
||||
Reference in New Issue
Block a user