django / channels

Developer-friendly asynchrony for Django

Home Page:https://channels.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentication Hash Problem

prxful opened this issue · comments

commented

Hi Dev,
I'm use Django 4.0.3 & i see some error.. well we can;t say error but its bug

Django = 4.0.3
Linux x64
1
In this.. Create user generate password field with encryption.
So, we can auth & login successfully

2

Column 2 & 3 created by python manage.py shell
Column 1 created by view.py

Default User.object.create_user() in view.py dont make hash password & save plain text..
So, it's unsuccessful when we do login.

Please Fix

Good day!

Proper way of setting password for Django User is: 'user.set_password("password")'and 'user.save()'. This way the password will be hashed.

For more information: https://stackoverflow.com/questions/30466191/django-set-password-isnt-hashing-passwords

Good day!

Proper way of setting password for Django User is: 'user.set_password("password")'and 'user.save()'. This way the password will be hashed.

For more information: https://stackoverflow.com/questions/30466191/django-set-password-isnt-hashing-passwords

Nope.. I try this.. not working in Django 4.0.3
you can try too .. in View.py not using in Shell

The Bug is.. user.set_password() not hash the normal text.
for this u need to use make_password to make them hash then store via user.set_password() & user.save()

@MrR1pp3r, could you please take a look at this example: git@github.com:almazkun/django_password_hash.git?

There are 2 endpoints to create a user. It is saving hashed passwords.

Or please share your code. It will be easier to debug.

Thank you! =)

@almazkun, i see your repo.. i use the same method
here u go
user
i send you video too.. wait for 10 minutes

@almazkun

@MrR1pp3r, could you please take a look at this example: git@github.com:almazkun/django_password_hash.git?

There are 2 endpoints to create a user. It is saving hashed passwords.

Or please share your code. It will be easier to debug.

Thank you! =)

@MrR1pp3r, could you please take a look at this example: git@github.com:almazkun/django_password_hash.git?

There are 2 endpoints to create a user. It is saving hashed passwords.

Or please share your code. It will be easier to debug.

Thank you! =)

Problem is I can create user via terminal .. but i can't make hash password via drf api

carbon

Good day! =)

Maybe this is the problem:
Screen Shot 2022-04-04 at 6 50 27 PM
Could you try this instead: user.set_password(raw_password)?

like here: https://github.com/almazkun/django_startapp/blob/05eb1f9b4177346fb92170b3651ca5b5a756558d/apps/accounts/models.py#L23

Good day! =)

Maybe this is the problem: Screen Shot 2022-04-04 at 6 50 27 PM Could you try this instead: user.set_password(raw_password)?

like here: https://github.com/almazkun/django_startapp/blob/05eb1f9b4177346fb92170b3651ca5b5a756558d/apps/accounts/models.py#L23

I try every thing.. set_password(password), make_hash(password) & user.password = make_hash(password)

I find the solution but.. i need to call create_user() twice ....

First, models.py where i make custom user method.. & the next call in Serializer.. when create user.

Actually i use ModelSerializer So, i predict.. i need to just use META & FIELDS,, but later i override CREATE() & BOOOOOM its working.

`def create(self, validated_data):
username = validated_data.pop('username')
password = validated_data.pop('password')

user = get_user_model().objects.create_user(username=username, **validated_data)
user.set_password(password)
user.save()
return user`

& Thanx For The Code. ( I learn about customForm )

Would you mind closing the issue? :)