diff --git a/.gitignore b/.gitignore index bb18dc3..a6bf882 100644 --- a/.gitignore +++ b/.gitignore @@ -205,4 +205,5 @@ cython_debug/ marimo/_static/ marimo/_lsp/ __marimo__/ -bancho.py-master/* \ No newline at end of file +bancho.py-master/* +.vscode/settings.json diff --git a/app/auth.py b/app/auth.py index 45afba7..7bebdd5 100644 --- a/app/auth.py +++ b/app/auth.py @@ -84,7 +84,7 @@ def authenticate_user_legacy(db: Session, name: str, password: str) -> Optional[ return None # 3. 验证密码 - if not user.pw_bcrypt: + if not (user.pw_bcrypt is None and user.pw_bcrypt != ""): return None # 4. 检查缓存 diff --git a/app/database.py b/app/database.py index 31d3d6a..5bf536a 100644 --- a/app/database.py +++ b/app/database.py @@ -147,6 +147,7 @@ class User(Base): lazer_replays_watched = relationship( "LazerUserReplaysWatched", back_populates="user", cascade="all, delete-orphan" ) + # ============================================ diff --git a/app/router/auth.py b/app/router/auth.py index afe4cf2..634a463 100644 --- a/app/router/auth.py +++ b/app/router/auth.py @@ -60,7 +60,7 @@ async def oauth_token( # 存储令牌 store_token( db, - user.id, + getattr(user, "id"), access_token, refresh_token_str, settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60, @@ -92,9 +92,10 @@ async def oauth_token( new_refresh_token = generate_refresh_token() # 更新令牌 + user_id = int(getattr(token_record, 'user_id')) store_token( db, - token_record.user_id, + user_id, access_token, new_refresh_token, settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60, diff --git a/app/utils.py b/app/utils.py index 75021a8..7eab233 100644 --- a/app/utils.py +++ b/app/utils.py @@ -58,9 +58,9 @@ def convert_db_user_to_api_user( user_stats = create_default_lazer_statistics(ruleset) # 获取国家信息 - country_code = db_user.country_code if db_user.country_code else "XX" + country_code = db_user.country_code if db_user.country_code is not None else "XX" - country = Country(code=country_code, name=get_country_name(country_code)) + country = Country(code=str(country_code), name=get_country_name(str(country_code))) # 获取 Kudosu 信息 kudosu = Kudosu(available=0, total=0) @@ -346,7 +346,7 @@ def convert_db_user_to_api_user( id=user_id, username=user_name, avatar_url=avatar_url, - country_code=country_code, + country_code=str(country_code), default_group=profile.default_group if profile else "default", is_active=profile.is_active if profile else True, is_bot=profile.is_bot if profile else False,