fix: asegurar que la clave del admin por defecto se restablece a Admin1234! en cada inicio

This commit is contained in:
Carlos Tello
2026-08-15 01:01:00 -03:00
parent 929f9affd7
commit 3b74a7ba65
+7 -1
View File
@@ -38,7 +38,7 @@ async def lifespan(app: FastAPI):
os.makedirs(path, exist_ok=True) os.makedirs(path, exist_ok=True)
storage_provider.root_dir = path storage_provider.root_dir = path
result = await session.execute(select(User)) result = await session.execute(select(User).where(User.email == "admin@oneverdrive.local"))
admin = result.scalar_one_or_none() admin = result.scalar_one_or_none()
if not admin: if not admin:
admin_user = User( admin_user = User(
@@ -51,6 +51,12 @@ async def lifespan(app: FastAPI):
session.add(admin_user) session.add(admin_user)
await session.commit() await session.commit()
print(">> [OnEver Drive] Default admin created: admin@oneverdrive.local / Admin1234!") print(">> [OnEver Drive] Default admin created: admin@oneverdrive.local / Admin1234!")
else:
admin.hashed_password = get_password_hash("Admin1234!")
admin.is_active = True
session.add(admin)
await session.commit()
print(">> [OnEver Drive] Default admin verified & password reset to: Admin1234!")
yield yield