Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ docker compose build
docker compose up -d
```

If you set `SERVER_EMAIL` and `SERVER_PASS`, you can approve Gaijin Pass requests on your device while the server runs in the background. If the server account uses an email code, start the service with an interactive terminal and enter the code within 15 minutes.

## Contributions
Contributions are welcome.
Pull requests that improve ThunderAPI without breaking existing functionality are encouraged
Expand Down
24 changes: 3 additions & 21 deletions src/api/v1/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from api.v1.models import GenericEmptyResponse
from api.v1.shared import TokenBearer
from utils import users_auth
from utils.auth import _PENDING_2FA
from utils.helper import dtToTimestamp

from .models import Login, LoginToken
Expand Down Expand Up @@ -39,11 +38,7 @@ async def login_post(
):
token, uidHint = await users_auth.login(email, password)

return JSONResponse({
"status": "OK",
"token": token,
"user_id": uidHint
}, status_code = status.HTTP_200_OK)
return Login.LoginResponse(token = token, user_id = uidHint)

@router.post(
"/refresh-token",
Expand Down Expand Up @@ -82,21 +77,8 @@ async def answer_2fa(
password: Annotated[str, Form(title = "The password of the account, used as a sort of protection")],
code: Annotated[str, Form(title = "The 2FA code")]
):
if email not in _PENDING_2FA:
raise HTTPException(status.HTTP_404_NOT_FOUND, "You are not pending 2FA verification. Please try to log in first.")
if _PENDING_2FA[email].check_password(password):
_PENDING_2FA[email].code = code
_PENDING_2FA[email].provided.set()
else:
raise HTTPException(status.HTTP_401_UNAUTHORIZED, "Invalid password")
# TODO: Implement. Due to the nature of the 2FA system, it is hard to implement
token, uidHint = await users_auth.login(email, password)

return JSONResponse({
"status": "OK",
"token": token,
"user_id": uidHint
}, status_code = status.HTTP_200_OK)
token, uidHint = await users_auth.login(email, password, code = code)
return Login.LoginResponse(token = token, user_id = uidHint)

@router.delete(
"/remove",
Expand Down
6 changes: 3 additions & 3 deletions src/api/v1/marketplace/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def from_json(cls, data:dict[str, Any], user: LoginEntry, itemData: dict[str, An

return cls(
LOGIN = user,
commodity = assetData.get("commodity"),
commodity = assetData.get("commodity") or False,
description = assetData["descriptions"][0]["value"],
icon_url = assetData.get("icon_url"),
icon_url_large = assetData.get("icon_url_large"),
Expand Down Expand Up @@ -205,7 +205,7 @@ def from_dict(cls, data:dict[str, Any]):
return cls(
hash_name = data["hash_name"],
name = data["name"],
commodity = data.get("commodity", False),
commodity = data.get("commodity") or False,
icon = data["icon"],
buy_price = data["buy_price"] / 100000000,
buy_orders = data["buy_depth"],
Expand All @@ -220,7 +220,7 @@ def from_assetdata(cls, assetData:dict[str, Any], ordersData: dict[str, Any], cl
return cls(
hash_name = assetData["market_hash_name"],
name = assetData["market_name"],
commodity = assetData.get("commodity", False),
commodity = assetData.get("commodity") or False,
icon = assetData.get("icon_url_large", assetData.get("icon_url", None)),
buy_price = max((i[0] for i in ordersData.get("BUY", [])), default = 0) / 10000,
buy_orders = ordersData["depth"].get("BUY", 0),
Expand Down
Loading
Loading