add product

This commit is contained in:
javad committed 2026-10-08 16:37:45 +03:30
1 parent 423d4cf40e
commit c8d45dd07c
58 files changed
+8309 -674

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
from rest_framework.exceptions import AuthenticationFailed
from rest_framework_simplejwt.authentication import JWTAuthentication
from apps.jwt_auth.models import JwtToken
from apps.jwt_auth.session import validate_session_claims
class SessionJWTAuthentication(JWTAuthentication):
"""A signed JWT is usable only while its recorded session remains active."""
def get_user(self, validated_token):
user = super().get_user(validated_token)
session = JwtToken.objects.select_related('cuser_role__role_type', 'cuser_role__sys_ws', 'cuser_role__cuser').filter(
access=str(validated_token), cuser=user, is_blocked=False,
).first()
if not session:
raise AuthenticationFailed('نشست شما معتبر نیست. لطفاً دوباره وارد شوید.', code='session_invalid')
validate_session_claims(session, validated_token)
return user