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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies = [
"pyjwt>=2.10.1",
"faststream[rabbit]>=0.5.39",
"starlette>=0.46.2",
"django-extensions>=4.1",
"uvicorn>=0.34.2",
]

Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/User.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def set_account_pin(request: HttpRequest, user_pin: Pin) -> tuple:
"/",
response={
HTTPStatus.OK: SuccessResponse[UserResponse],
HTTPStatus.BAD_REQUEST: ErrorResponse,
HTTPStatus.NOT_FOUND: ErrorResponse,
HTTPStatus.INTERNAL_SERVER_ERROR: ServerErrorResponse,
},
)
Expand Down
8 changes: 4 additions & 4 deletions src/api/routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ async def home(request: HttpRequest) -> dict:
return {"message": "Hello, World!"}


api.add_router("/users", "src.api.routes.User.router", tags=["User"])
api.add_router("/kyc", "src.api.routes.UserKYC.router", tags=["User KYC"])
api.add_router("/users/profile", "src.api.routes.User.router", tags=["User"])
api.add_router("/users/kyc", "src.api.routes.UserKYC.router", tags=["User KYC"])
api.add_router(
"/next-of-kin",
"/users/next-of-kin",
"src.api.routes.UserNOK.router",
tags=["User NOK"],
)
api.add_router(
"/withdrawal-accounts",
"/users/withdrawal-accounts",
"src.api.routes.WithdrawalAccount.router",
tags=["User"],
)
5 changes: 3 additions & 2 deletions src/api/services/UserService.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ async def update(self, id: str, req: UpdateUserRequest) -> UserSuccess:
id, req.model_dump(exclude_unset=True)
)

message = MESSAGES["USER"]["UPDATED"]
self.logger.info(
{
"activity_type": ACTIVITY_TYPES["UPDATE_USER"],
"message": MESSAGES["USER"]["UPDATED"],
"message": message,
"metadata": {
"user": {"id": id},
"new_data": req.model_dump(exclude_unset=True),
Expand All @@ -117,7 +118,7 @@ async def update(self, id: str, req: UpdateUserRequest) -> UserSuccess:
)
user = self.utility_service.sanitize_user_object(updated_user)

return {"is_success": True, "user": user}
return {"is_success": True, "message": message, "user": user}

@staticmethod
@UserRouter.subscriber(queue=QUEUE_NAMES["USER_REGISTRATION"])
Expand Down
8 changes: 4 additions & 4 deletions src/api/services/UtilityService.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import hashlib
from uuid import uuid4
from typing import TypedDict
from datetime import datetime, timedelta
from datetime import UTC, datetime, timedelta

import jwt
import bcrypt
Expand Down Expand Up @@ -123,10 +123,10 @@ def verify_signature(signature_data: SignatureData, logger: Logger) -> bool:
)
raise AuthenticationError(message=message)

initial_time = datetime.fromtimestamp(float(timestamp) / 1000)
initial_time = datetime.fromtimestamp(float(timestamp), UTC)
valid_window = initial_time + timedelta(minutes=ttl)

if valid_window < datetime.now():
if valid_window < datetime.now(UTC):
message = "Signature expired!"
logger.error(
{
Expand All @@ -141,5 +141,5 @@ def verify_signature(signature_data: SignatureData, logger: Logger) -> bool:

@staticmethod
def get_timestamp() -> str:
current_time = datetime.now().timestamp() * 1000
current_time = datetime.now(UTC).timestamp()
return str(current_time)
1 change: 0 additions & 1 deletion src/config/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

THIRD_PARTY_APPS = [
"corsheaders",
"django_extensions",
]

INSTALLED_APPS = [
Expand Down
4 changes: 2 additions & 2 deletions src/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class Queue(TypedDict):
}

queue: Queue = {
"key": get_env_str("QUEUE_SECRECT_KEY"),
"ttl": get_env_float("QUEUE_SECRECT_KEY_TTL"),
"key": get_env_str("QUEUE_SECRET_KEY"),
"ttl": get_env_float("QUEUE_SECRET_KEY_TTL"),
}

otp: OTP = {"lifetime": get_env_int("OTP_LIFETIME")}
Expand Down
110 changes: 48 additions & 62 deletions uv.lock

Large diffs are not rendered by default.