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

safe get key for request.META #40

Merged
merged 1 commit into from
May 10, 2019

Conversation

talbenbasat
Copy link
Contributor

No description provided.

@talbenbasat
Copy link
Contributor Author

@anx-ckreuzberger can you please check and merge

@anx-ckreuzberger
Copy link
Contributor

PR looks fine, but I'm not sure if this is a behaviour that I would want to support without notifying the dev/admin about it.

I think I'll make those "default values" configureable in Django Settings.

@talbenbasat
Copy link
Contributor Author

talbenbasat commented Apr 9, 2019

sounds good added those values..
let me know if there's any way I can help

@anx-ckreuzberger
Copy link
Contributor

Thanks!

@bentappin
Copy link

bentappin commented Jun 28, 2019

It might better to allow users to set the name of the header rather than providing default values if the REMOTE_ADDR is not found?

E.g. so essentially allowing to user to say "hey use HTTP_X_REAL_IP not REMOTE_ADDR please"

Perhaps something like this:

user_agent_header = getattr(settings, 'DJANGO_REST_PASSWORDRESET_HTTP_USER_AGENT_HEADER', 'HTTP_USER_AGENT')
ip_address_header = getattr(settings, 'DJANGO_REST_PASSWORDRESET_IP_ADDRESS_HEADER', 'REMOTE_ADDR')

token = ResetPasswordToken.objects.create(
    user=user,
    user_agent=request.META.get(user_agent_header),
    ip_address=request.META.get(ip_address_header)
)

@anx-ckreuzberger
Copy link
Contributor

anx-ckreuzberger commented Jul 24, 2019

I believe the implementation suggested by @vonorm is correct, the original implementation coming from the Merge Request is faulty.

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.

3 participants