File Cabinet MVP: case detail with inline Ledger CRUD
- Extend Transaction with ledger fields (item_no, employee_number, t_code, t_type_l, quantity, rate, billed) - Startup SQLite migration to add missing columns on transactions - Ledger create/update/delete endpoints with validations and auto-compute Amount = Quantity × Rate - Uniqueness: ensure (transaction_date, item_no) per case by auto-incrementing - Compute case totals (billed/unbilled/overall) and display in case view - Update case.html for master-detail ledger UI; add client-side auto-compute JS - Enhance import_ledger_data to populate extended fields - Close/Reopen actions retained; case detail sorting by date/item - Auth: switch to pbkdf2_sha256 default (bcrypt fallback) and seed admin robustness Tested in Docker: health OK, login OK, import ROLODEX/FILES OK, ledger create persisted and totals displayed.
This commit is contained in:
22
app/auth.py
22
app/auth.py
@@ -12,7 +12,8 @@ from .models import User
|
||||
from .database import SessionLocal
|
||||
|
||||
# Configure password hashing context
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
# Prefer pbkdf2_sha256 for portability; include bcrypt for legacy compatibility
|
||||
pwd_context = CryptContext(schemes=["pbkdf2_sha256", "bcrypt"], deprecated="auto")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -140,7 +141,24 @@ def seed_admin_user() -> None:
|
||||
# Check if admin user already exists
|
||||
existing_admin = db.query(User).filter(User.username == admin_username).first()
|
||||
if existing_admin:
|
||||
logger.info(f"Admin user '{admin_username}' already exists")
|
||||
# Ensure default credentials work in development
|
||||
needs_reset = False
|
||||
try:
|
||||
needs_reset = not verify_password(admin_password, existing_admin.password_hash)
|
||||
except Exception as e:
|
||||
logger.warning(f"Password verify failed for admin (will reset): {e}")
|
||||
needs_reset = True
|
||||
|
||||
if needs_reset:
|
||||
try:
|
||||
existing_admin.password_hash = hash_password(admin_password)
|
||||
db.add(existing_admin)
|
||||
db.commit()
|
||||
logger.info(f"Admin user '{admin_username}' password reset to default")
|
||||
except Exception as e:
|
||||
logger.error(f"Error updating admin password: {e}")
|
||||
else:
|
||||
logger.info(f"Admin user '{admin_username}' already exists")
|
||||
return
|
||||
|
||||
# Create admin user
|
||||
|
||||
Reference in New Issue
Block a user