Skip to content

Conversation

@epou
Copy link
Member

@epou epou commented Oct 28, 2025

No description provided.

@epou epou requested a review from Copilot October 28, 2025 15:11
@epou epou self-assigned this Oct 28, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that newly created TigaUser instances are assigned a default password by modifying the password field to include a default value generator. Previously, the password field was nullable, which could allow users without passwords.

Key Changes:

  • Added a default password configuration in settings
  • Modified TigaUser model to automatically hash and assign default password
  • Added test coverage to verify the default password is set correctly

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tigaserver_project/settings.py Introduces DEFAULT_TIGAUSER_PASSWORD constant for configuring the default password
tigaserver_app/models.py Adds get_default_password_hash() function and updates TigaUser.password field to use it as default
tigaserver_app/tests/tests.py Adds test assertion to verify new users are created with the default password
tigaserver_app/migrations/0087_alter_tigauser_password.py Django migration to apply the password field default change

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +36
# Change this in prod
DEFAULT_TIGAUSER_PASSWORD = 'TEST_PASSWORD'
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding a default password in settings is a security risk, especially with DEBUG=False in production. Consider using environment variables or Django's secrets management to configure this value securely, and ensure it's overridden in production environments.

Suggested change
# Change this in prod
DEFAULT_TIGAUSER_PASSWORD = 'TEST_PASSWORD'
# Set this via environment variable in production
DEFAULT_TIGAUSER_PASSWORD = os.environ.get('DEFAULT_TIGAUSER_PASSWORD')

Copilot uses AI. Check for mistakes.
Comment on lines +174 to +175
def get_default_password_hash():
return make_password(settings.DEFAULT_TIGAUSER_PASSWORD)
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called every time a TigaUser instance is created, hashing the same password repeatedly. Since the default password is static, consider caching the hash result to avoid unnecessary computation on each user creation.

Copilot uses AI. Check for mistakes.
USERNAME_FIELD = 'pk'

password = models.CharField(_('password'), max_length=128, null=True, blank=True)
password = models.CharField(_('password'), max_length=128, default=get_default_password_hash)
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing null=True and blank=True from the password field may cause issues for existing TigaUser records that have NULL passwords. Consider adding a data migration to populate existing NULL passwords before applying this schema change.

Copilot uses AI. Check for mistakes.
@epou epou merged commit 233fbad into master Nov 11, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants