fixed ChangePasswordView

This commit is contained in:
Anatoly 2019-09-12 09:33:09 +03:00
parent f8c795cd03
commit 2c41e532c8
4 changed files with 9 additions and 11 deletions

View File

@ -34,8 +34,7 @@ class ChangePasswordView(JWTUpdateAPIView):
def get_object(self):
"""Overridden get_object method."""
if not self.request.user.is_authenticated():
queryset = self.filter_queryset(self.get_queryset())
if not self.request.user.is_authenticated:
uidb64 = self.kwargs.get('uidb64')
user_id = force_text(urlsafe_base64_decode(uidb64))
@ -47,7 +46,8 @@ class ChangePasswordView(JWTUpdateAPIView):
if not GMTokenGenerator(GMTokenGenerator.RESET_PASSWORD).check_token(
user=password_reset_obj.user, token=token):
raise utils_exceptions.NotValidAccessTokenError()
# todo: Add is_valid check status
if not password_reset_obj.user.is_active:
raise utils_exceptions.UserNotFoundError()
obj = password_reset_obj.user
else:
obj = self.request.user
@ -58,7 +58,8 @@ class ChangePasswordView(JWTUpdateAPIView):
def patch(self, request, *args, **kwargs):
"""Implement PUT method"""
serializer = self.get_serializer(instance=self.request.user,
instance = self.get_object()
serializer = self.get_serializer(instance=instance,
data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()

View File

@ -137,8 +137,8 @@ class WrongAuthCredentials(AuthErrorMixin):
class FavoritesError(exceptions.APIException):
"""
The exception should be thrown when you item that user
want add to favorites already exists.
The exception should be thrown when item that user
want to add to favorites is already exists.
"""
status_code = status.HTTP_400_BAD_REQUEST
default_detail = _('Item is already in favorites.')

View File

@ -2,10 +2,7 @@
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
<a href="https://{{ country_code }}.{{ domain_uri }}/recovery/{{ uidb64 }}/{{ token }}/">Reset link.</a>
{% endblock %}
<a href="https://{{ country_code }}.{{ domain_uri }}/recovery/{{ uidb64 }}/{{ token }}/">https://{{ country_code }}.{{ domain_uri }}/recovery/{{ uidb64 }}/{{ token }}/</a>
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}

View File

@ -3,7 +3,7 @@
{% trans "Please confirm your email address to complete the registration:" %}
<a href="https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/">Confirmation link.</a>
<a href="https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/">https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/</a>
{% trans "Thanks for using our site!" %}