Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to reset password of other user #3528

Closed
seancolsen opened this issue Apr 10, 2024 · 2 comments · Fixed by #3536
Closed

Error when trying to reset password of other user #3528

seancolsen opened this issue Apr 10, 2024 · 2 comments · Fixed by #3536
Labels
help wanted Community contributors can implement this ready Ready for implementation work: backend Related to Python, Django, and simple SQL
Milestone

Comments

@seancolsen
Copy link
Contributor

Steps to reproduce

  1. Set up another Mathesar user (other than the one you're logged in as).

  2. Edit the another user and try to reset their password.

  3. Observe this error message:

    image

    An API request is made to /api/ui/v0/users/2/password_reset/ which returns a Django error

    AttributeError at /api/ui/v0/users/2/password_reset/

    'PasswordResetSerializer' object has no attribute 'validate_password'

    Traceback
    Environment:
    
    
    Request Method: POST
    Request URL: http://localhost:8000/api/ui/v0/users/2/password_reset/
    
    Django Version: 4.2.10
    Python Version: 3.9.19
    Installed Applications:
    ['django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
    'rest_framework',
    'django_filters',
    'django_property_filter',
    'drf_spectacular',
    'mathesar']
    Installed Middleware:
    ['django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'mathesar.middleware.CursorClosedHandlerMiddleware',
    'mathesar.middleware.PasswordChangeNeededMiddleware',
    'django_userforeignkey.middleware.UserForeignKeyMiddleware',
    'django_request_cache.middleware.RequestCacheMiddleware']
    
    
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
        response = get_response(request)
      File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
        return view_func(*args, **kwargs)
      File "/usr/local/lib/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
        return self.dispatch(request, *args, **kwargs)
      File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
        response = self.handle_exception(exc)
      File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 466, in handle_exception
        response = exception_handler(exc, context)
      File "/code/mathesar/exception_handlers.py", line 63, in mathesar_exception_handler
        raise exc
      File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
        response = handler(request, *args, **kwargs)
      File "/code/mathesar/api/ui/viewsets/users.py", line 29, in password_reset
        serializer.is_valid(raise_exception=True)
      File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 235, in is_valid
        raise ValidationError(self.errors)
      File "/code/mathesar/api/exceptions/mixins.py", line 98, in errors
        pretty_errors = self.build_pretty_errors(ugly_errors)
      File "/code/mathesar/api/exceptions/mixins.py", line 64, in build_pretty_errors
        pretty.extend(self.get_field_error_entries(errors[error_type], field))
      File "/usr/local/lib/python3.9/site-packages/rest_framework_friendly_errors/mixins.py", line 180, in get_field_error_entries
        return [self.get_field_error_entry(error, field) for error in errors]
      File "/usr/local/lib/python3.9/site-packages/rest_framework_friendly_errors/mixins.py", line 180, in <listcomp>
        return [self.get_field_error_entry(error, field) for error in errors]
      File "/usr/local/lib/python3.9/site-packages/rest_framework_friendly_errors/mixins.py", line 168, in get_field_error_entry
        validator = getattr(self, "validate_%s" % field.field_name)
    
    Exception Type: AttributeError at /api/ui/v0/users/2/password_reset/
    Exception Value: 'PasswordResetSerializer' object has no attribute 'validate_password'
    

I can reproduce this on the latest develop branch as well as the most recent release (Mathesar 0.1.6).

@seancolsen seancolsen added help wanted Community contributors can implement this ready Ready for implementation type: bug work: backend Related to Python, Django, and simple SQL labels Apr 10, 2024
@seancolsen seancolsen added this to the Backlog milestone Apr 10, 2024
@camicacace
Copy link

Hi, can I work on this issue?

@seancolsen
Copy link
Contributor Author

Sure, @camicacace you're welcome to submit a PR. Ask here or in Matrix if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Community contributors can implement this ready Ready for implementation work: backend Related to Python, Django, and simple SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants