truncate passwords to 72 bytes to prevent bcrypt hashing errors

This commit is contained in:
CPTN Cosmo 2026-04-18 17:03:09 +02:00
parent bb7053b01e
commit 7dcda4b5ef
2 changed files with 5 additions and 3 deletions

View file

@ -37,10 +37,11 @@ app = FastAPI()
app.add_middleware(SessionMiddleware, secret_key=ENCRYPTION_KEY)
def get_password_hash(password):
return pwd_context.hash(password)
# bcrypt has a 72-byte limit
return pwd_context.hash(password[:72])
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
return pwd_context.verify(plain_password[:72], hashed_password)
def init_db():
conn = sqlite3.connect(DB_PATH)