fixed expiring login creds

This commit is contained in:
David Bruno Vontor
2026-05-19 16:52:55 +02:00
parent 6cec6fbb94
commit c7de2dbcdc
30 changed files with 163 additions and 69 deletions

View File

@@ -77,6 +77,9 @@ class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
if user is None or not user.check_password(password):
raise serializers.ValidationError(_("No active account found with the given credentials"))
if not user.is_active:
raise serializers.ValidationError(_("Tento účet není aktivní. Ověřte prosím svůj e-mail."))
# Call the parent validation to create token
data = super().validate({
self.username_field: user.username,

View File

@@ -86,26 +86,7 @@ class CookieTokenObtainPairView(TokenObtainPairView):
)
return response
def validate(self, attrs):
username = attrs.get("username")
password = attrs.get("password")
# Přihlaš uživatele ručně
user = authenticate(request=self.context.get('request'), username=username, password=password)
if not user:
raise AuthenticationFailed("Špatné uživatelské jméno nebo heslo.")
if not user.is_active:
raise AuthenticationFailed("Uživatel je deaktivován.")
# Nastav validní uživatele (přebere další logiku ze SimpleJWT)
self.user = user
# Vrátí access a refresh token jako obvykle
return super().validate(attrs)
@extend_schema(
tags=["account", "public"],
summary="Refresh JWT token using cookie",