example on orm typing (#23322)

This commit is contained in:
Asuka Minato 2025-08-26 19:16:58 +09:00 • committed by GitHub
commit 58165c3951
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 9 deletions

View file

@ -17,6 +17,7 @@ def encrypt_token(tenant_id: str, token: str):
if not (tenant := db.session.query(Tenant).where(Tenant.id == tenant_id).first()):
raise ValueError(f"Tenant with id {tenant_id} not found")
assert tenant.encrypt_public_key is not None
encrypted_token = rsa.encrypt(token, tenant.encrypt_public_key)
return base64.b64encode(encrypted_token).decode()