Skip to content

feat(accounts): include API token reset on password change#19057

Merged
nijel merged 1 commit intoWeblateOrg:mainfrom
nijel:token
Apr 17, 2026
Merged

feat(accounts): include API token reset on password change#19057
nijel merged 1 commit intoWeblateOrg:mainfrom
nijel:token

Conversation

@nijel
Copy link
Copy Markdown
Member

@nijel nijel commented Apr 17, 2026

When the password change is triggered by a compromise user might not realize that the API token might be compromised as well.

@nijel nijel added this to the 5.17.1 milestone Apr 17, 2026
@nijel nijel self-assigned this Apr 17, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 048585d13e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread weblate/accounts/forms.py
Copy link
Copy Markdown
Contributor

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 updates the account password-change/reset flows to optionally revoke and regenerate the user’s DRF API token, defaulting to regeneration to better protect users in compromise scenarios.

Changes:

  • Added API token helper utilities (create_api_token, delete_api_tokens, reset_api_token) and reused them across account flows.
  • Extended SetPasswordForm with a “Regenerate API key” checkbox (default enabled) and resets the token on password change/reset when enabled.
  • Updated tests and changelog entry to reflect the new default behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
weblate/accounts/views.py Refactors the “reset API key” endpoint to use the shared reset_api_token() helper.
weblate/accounts/utils.py Introduces centralized API token creation/deletion/reset helpers and reuses deletion during user removal.
weblate/accounts/models.py Reuses shared token creation helper during user-profile creation to avoid duplicating token generation logic.
weblate/accounts/forms.py Adds the “Regenerate API key” option to password changes/resets and performs the reset when enabled.
weblate/accounts/tests/test_views.py Verifies password change regenerates the API token when requested, and preserves it when not.
weblate/accounts/tests/test_registration.py Updates registration/password-reset tests to cover default regeneration and explicit “keep key” behavior.
docs/changes.rst Documents the new default behavior (API key regeneration on password updates).

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

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 11 changed Apr 17, 2026, 1:13 PM

When the password change is triggered by a compromise user might not
realize that the API token might be compromised as well.
@nijel nijel merged commit 649a2da into WeblateOrg:main Apr 17, 2026
51 of 53 checks passed
@nijel nijel deleted the token branch April 17, 2026 15:31
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