Friday, June 17, 2016

Re: Authenticate problem

usu.password shouldn't be "secret" (as in plain text "secret") it should be hashed.

Try doing 

usu.set_password('secret')
usu.save() # Not sure if it is necessary or set_password saves by itself

then 

user = authenticate(username='john', password='secret')


On Sat, Jun 18, 2016 at 6:33 AM, Briel <brielsantana@gmail.com> wrote:
Hi
I'm trying to use authenticate like the documentation shown at djangoproject, and when I try this authenticate returns None, although the user is registered, and the password is right:


from django.contrib.auth import authenticate

...


user = authenticate(username='john', password='secret') #None

usu = User.objects.get(username='john') # usu.password == 'secret'


is there something wrong?
Thank you a lot

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5296d661-e84c-4dda-bfbf-ba93c845aa9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei2wn1Whn5h7Djt3V4Ou6%3DnHrrRbpzfx2XMbopKh%2BHziTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment