Skip to content

Delete and regenerate backup codes in a single transaction#10686

Merged
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/backup-codes
May 23, 2024
Merged

Delete and regenerate backup codes in a single transaction#10686
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/backup-codes

Conversation

@mitchellhenke
Copy link
Contributor

🛠 Summary of changes

Currently, we generate codes, delete codes, and save new codes separately. This can be kind of difficult to follow, and can be harder to safely manage backup codes. This PR simplifies the API for the BackupCodeGenerator by reducing the available operations to only delete_and_regenerate and the verification methods.

changelog: Internal, Performance, Delete and regenerate backup codes in a single transaction
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/backup-codes branch from 9e62ba2 to e934123 Compare May 23, 2024 14:40
@mitchellhenke mitchellhenke requested a review from a team May 23, 2024 15:16
@mitchellhenke mitchellhenke merged commit 4a9ebd5 into main May 23, 2024
@mitchellhenke mitchellhenke deleted the mitchellhenke/backup-codes branch May 23, 2024 15:45
codes = generate_new_codes

BackupCodeConfiguration.transaction do
@user.backup_code_configurations.destroy_all
Copy link
Contributor

Choose a reason for hiding this comment

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

delete_all would be slightly faster than destroy_all because it doesn't run callbacks for each object? and since backup codes are like leaf nodes, there shouldn't be anything to destroy?

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.

3 participants