fix(credential): desacople modal qr vs carnet completo, dni y usuario en perfil, y resolucion robusta en dni parser v3.8.54

This commit is contained in:
2026-10-28 15:22:17 -03:00
parent b752493a74
commit 1ce6ca0ea5
23 changed files with 334 additions and 156 deletions
+23
View File
@@ -49,6 +49,27 @@ class User(db.Model):
from app.constants.document_types import format_document
return format_document(self.document_type, self.document_number)
@property
def username(self) -> str:
"""Alias o identificador de acceso: DNI o prefijo de email institucional."""
if self.document_number:
return self.document_number
if self.email and '@' in self.email:
return self.email.split('@')[0]
return self.email or f"user_{self.id}"
@property
def auth_provider_label(self) -> str:
"""Determina la procedencia y mecanismo de autenticación del usuario."""
ph = str(self.password_hash or '')
if ph.startswith('GoogleSSO_'):
return 'Google Workspace (@unicaba.edu.ar)'
if ph.startswith('MoodleLinked_'):
return 'Moodle Campus Virtual'
if self.email and self.email.endswith('@unicaba.edu.ar'):
return 'Institucional UniCABA'
return 'Cuenta Local'
# Relationships
reservations = db.relationship('Reservation', backref='user', lazy=True, cascade='all, delete-orphan')
@@ -164,6 +185,8 @@ class User(db.Model):
'document_type': self.document_type or 'DNI',
'document_number': self.document_number or '',
'document_formatted': self.get_formatted_document(),
'username': self.username,
'auth_provider_label': self.auth_provider_label,
'role': self.role,
'role_id': self.role_id,
'is_active': self.is_active,