Automatische Löschung von OTPPython

Python-Programme
Guest
 Automatische Löschung von OTP

Post by Guest »

Ich versuche eine Funktion zu erstellen, die automatisch OTP löscht, die in Fastapi abgelaufen sind. Py PrettyPrint-Override ">

Code: Select all

@app.on_event('startup')
@repeat_every(seconds=300)
async def delete_expired_otp(db: db_dependency):
print("deleting")
expired_otp = db.query(OTPModel).filter(OTPModel.expires_at < datetime.utcnow()).all()
if expired_otp:
for otp in expired_otp:
db.delete(otp)
db.commit()
print("deleted")
Ich habe sogar den Filter in is_used um wahr geändert, aber das hat nichts geändert.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post