Conversation
…add checking logic, and password initializaton for rooms
There was a problem hiding this comment.
Nice work. Few small notes. Also, no need to go back, but in the future it's best to keep migrations limited. For instance, in the future, if you were to create a new field and then rename it, all in a single PR/branch, then the migrations should be run fresh when the code is finalized.
Instead of having 0005_room_password_hash.py and 0006_auto_20200520_1724.py it could have been just a single migration creating the field with the proper name of password.
This starts to matter more on long-lived projects, where migrations keep getting tacked on.
apps/chatter/consumers.py
Outdated
| hashed_password = Room.objects.get(id=room_id).password | ||
| print('GOT HASHED PASSWORD ', hashed_password) | ||
| print('CHECKING PASSWORD ', password) | ||
| if hashed_password is '' or hashed_password is None: |
There was a problem hiding this comment.
Think this can be simplified as if not hased_password
| else: | ||
| validated_data['password'] = '' |
There was a problem hiding this comment.
If you had null=True on the password field, then you could skip having to set this to an empty string. Fore future reference.
apps/chatter/serializers.py
Outdated
|
|
||
| class MessageSerializer(serializers.Serializer): | ||
| command = serializers.ChoiceField(choices=['INIT_CHAT', 'FETCH_ENTRIES', 'NEW_ENTRY', 'ENTRIES']) | ||
| command = serializers.ChoiceField(choices=['INIT_CHAT', 'FETCH_ENTRIES', 'NEW_ENTRY']) |
There was a problem hiding this comment.
Wonder if this should reference the constants on the ChatConsumer class?
choices=[ChatConsumer.INIT_CHAT, ChatConsumer.FETCH_ENTRIES, ...]
Add password protection for rooms