[Answered ]-Logging in manually created userena user fails, why?

1๐Ÿ‘

โœ…

As a reference:

How to create a userena user manually

>>> my_user = UserenaSignup.objects.create_user(username="my_name", email="my_name@gmail.com", password="my_password")

# A userena user that hasn't activated his account with an account confirmation link
# has False for is_active
>>> my_user.is_active
False

How to activate an inactive userena user

>>> active_my_user = UserenaSignup.objects.activate_user(my_user.userena_signup.activation_key)
>>> active_my_user.is_active
True

I found this bit of code here, in the tests of Userena.

How to login a userena user manually

Logging in failed because only a user that has True for is_active can log in.
So after activating your user (see above) you log in as follows in a test:

self.client.login(username=active_my_user.username, password="my_password", email= active_my_user.email)
#True
๐Ÿ‘คBentley4

1๐Ÿ‘

I think that my_user.password is crypted.
Try this:

self.client.login(username=my_user.username, password='my_password')
๐Ÿ‘คDragos C

Leave a comment