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

Change lookup value to dynamic value #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martirella
Copy link

@martirella martirella commented Apr 24, 2020

Problem

This package is limited to recovering passwords by email

Solution

Make the lookup field dynamic so it can be used for any field.

Example

You want to recover a user by username,

  1. You set up the settings to DJANGO_REST_LOOKUP_FIELD= 'username'.

  2. When calling the API, the request body should be

{
  "username": "mycoolusername"
}

As a result, on the ResetPasswordRequestToken view the query will be username__iexact="mycoolusername".

Copy link
Contributor

@anx-cbenke anx-cbenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Universal approach to a user-defined lookup-field makes a lot of sense. I only ask you to explicate that it's not limited to email in the docs (Just insert a generic term instead of "custom_email_field", see the comment below)

Please also pull the recent changes from master and resolve the conflict in django_rest_passwordreset/views.py.

Comment on lines 144 to 148
## Custom Email Lookup

By default, `email` lookup is used to find the user instance. You can change that by adding
By default, `email` lookup is used to find the user instance. You can change that by adding
```python
DJANGO_REST_LOOKUP_FIELD = 'custom_email_field'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heading is no longer correct when the lookup-field can be anything, not only email.

'custom_email_field' should be changed to a more generic value too, to make clear that the lookup-field is not limited to an email-adress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants