Generate token with username/password

This commit is contained in:
DingZQ
2025-06-22 18:40:33 +08:00
parent 09ca1c43ec
commit eb49e2c849

View File

@@ -70,6 +70,8 @@ async def global_auth(request: Request):
app = FastAPI() app = FastAPI()
access_tokens = []
def generate_access_token(username: str, password: str) -> str: def generate_access_token(username: str, password: str) -> str:
""" """
根据用户名和密码生成JWT access token 根据用户名和密码生成JWT access token
@@ -100,7 +102,10 @@ def generate_access_token(username: str, password: str) -> str:
} }
# 生成并返回JWT token # 生成并返回JWT token
return jwt.encode(payload, SECRET_KEY, algorithm=ALGORITHM) token = jwt.encode(payload, SECRET_KEY, algorithm=ALGORITHM)
access_tokens.append(token)
return token