Initial commit: abyssVpn project
- Tauri desktop app (apps/desktop) - Python Django API service (services/api) - Deployment scripts and docs
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from django.http import HttpRequest
|
||||
|
||||
from accounts.models import User
|
||||
from accounts.services.jwt_service import decode_jwt
|
||||
|
||||
|
||||
def get_current_user(request: HttpRequest) -> User | None:
|
||||
auth = request.headers.get("Authorization", "")
|
||||
if not auth.startswith("Bearer "):
|
||||
return None
|
||||
try:
|
||||
payload = decode_jwt(auth.removeprefix("Bearer ").strip())
|
||||
return User.objects.get(id=payload["sub"], status=User.STATUS_ACTIVE)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user