Re: Authenticate problem

9 views
Skip to first unread message

Vijay Khemlani

unread,
Jun 17, 2016, 8:01:52 PM6/17/16
to django...@googlegroups.com
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 <briels...@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...@googlegroups.com.
To post to this group, send email to django...@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.

Reply all
Reply to author
Forward
0 new messages