Skip to content

Commit

Permalink
Finish feature/support-email-reset-pass
Browse files Browse the repository at this point in the history
Feature/support-email-reset-pass
  • Loading branch information
dragos-dobre authored Oct 29, 2024
2 parents c29ec74 + 9568a27 commit 47e1577
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/services/userServices.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from core.validation.obligatoryFieldValidation import validate_payload_for_obligatory_fields
from django.contrib.auth import authenticate
from rest_framework import exceptions
from core.utils import filter_validity
from django.db.models import Q

logger = logging.getLogger(__file__)

Expand Down Expand Up @@ -284,7 +286,15 @@ def check_user_unique_email(user_email):


def reset_user_password(request, username):
user = User.objects.get(username=username)
user = User.objects.filter(
Q(username=username) | Q(i_user__email=username),
*filter_validity(),
*filter_validity(prefix='i_user__')
).first()
# we don't want to inform is a username was not found
if not user:
return None

user.clear_refresh_tokens()

if not user.email:
Expand Down

0 comments on commit 47e1577

Please sign in to comment.