25 lines
849 B
Python
25 lines
849 B
Python
import asyncio
|
|||
|
|
from sqlalchemy import text
|
||
|
|
from sqlalchemy.ext.asyncio import create_async_engine
|
||
|
|
from app.core.security import create_access_token
|
||
|
|
DATABASE_URL = 'postgresql+asyncpg://scilit:scilit_prod_2026@postgres:5432/scilit'
|
||
|
|
async def main():
|
||
|
|
engine = create_async_engine(DATABASE_URL)
|
||
|
|
async with engine.connect() as conn:
|
||
|
|
r = await conn.execute(text("""
|
||
|
|
SELECT u.id, ut.tenant_id FROM users u
|
||
|
|
JOIN user_tenants ut ON ut.user_id = u.id
|
||
|
|
WHERE u.email = 'admin@scilit.cn'
|
||
|
|
"""))
|
||
|
|
u = r.first()
|
||
|
|
if u:
|
||
|
|
token = create_access_token(
|
||
|
|
user_id=str(u.id),
|
||
|
|
tenant_id=str(u.tenant_id),
|
||
|
|
role="admin",
|
||
|
|
is_superuser=True,
|
||
|
|
)
|
||
|
|
print(token)
|
||
|
|
await engine.dispose()
|
||
|
|
asyncio.run(main())
|