feat: cont demo public cu resetare automată a datelor la 3 ore

- Cont demo (demo@example.com/demo1234) activ implicit, identificat prin
  settings.demo_email — fără configurare în env; DEMO_EMAIL="" îl dezactivează
- Contul demo nu poate fi modificat prin API (email/parolă/status blocate 403)
- reset_demo.py: șterge idempotent toate datele demo și recrează proprietatea
  demo cu 3 spații și 5 rezervări exemplu cu date relative la ziua curentă
- entrypoint.sh: reset la boot + buclă la 3h (DEMO_RESET_INTERVAL)
- start.sh (dev): reset la fiecare pornire
- Login.vue: hint cu credențialele demo (click = precompletare) și mesajul
  de resetare la 3 ore

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-07-10 20:07:16 +00:00
parent c5a882ba6f
commit 98059a8a70
7 changed files with 311 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import BaseModel
from sqlalchemy.orm import Session
from app.core.demo import DEMO_LOCKED_DETAIL, is_demo_user
from app.core.deps import get_current_admin, get_current_manager_or_superadmin, get_current_user, get_db
from app.core.security import get_password_hash
from app.models.user import User
@@ -160,6 +161,9 @@ def update_user(
detail="User not found",
)
if is_demo_user(user):
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=DEMO_LOCKED_DETAIL)
# Check if new email conflicts with another user
if user_data.email and user_data.email != user.email:
existing = db.query(User).filter(User.email == user_data.email).first()
@@ -232,6 +236,9 @@ def update_user_status(
detail="User not found",
)
if is_demo_user(user):
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=DEMO_LOCKED_DETAIL)
setattr(user, "is_active", status_data.is_active)
db.commit()
@@ -259,6 +266,9 @@ def reset_user_password(
detail="User not found",
)
if is_demo_user(user):
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=DEMO_LOCKED_DETAIL)
setattr(user, "hashed_password", get_password_hash(reset_data.new_password))
db.commit()