feat: add set_username and set_password to DatabaseUser#579
Open
m4tx wants to merge 3 commits into
Open
Conversation
seqre
approved these changes
May 21, 2026
|
| Branch | database_user_methods |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 6,578.20 µs(+7.80%)Baseline: 6,102.49 µs | 7,699.78 µs (85.43%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 1,052.30 µs(-2.06%)Baseline: 1,074.49 µs | 1,323.73 µs (79.49%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 967.44 µs(-2.58%)Baseline: 993.03 µs | 1,204.49 µs (80.32%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 933.09 µs(-2.35%)Baseline: 955.50 µs | 1,167.97 µs (79.89%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 17,624.00 µs(-0.44%)Baseline: 17,701.50 µs | 21,171.80 µs (83.24%) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds public mutator methods on DatabaseUser to update a user’s username and password (with automatic hashing), enabling in-memory updates prior to persisting via the ORM.
Changes:
- Added
DatabaseUser::set_usernameto update theusernamefield. - Added
DatabaseUser::set_passwordto update thepasswordfield by hashing a providedPassword. - Added rustdoc examples for both new methods.
Comments suppressed due to low confidence (1)
cot/src/auth/db.rs:149
- The doc test example for
set_passwordalso usesDatabaseUser::new(...), which is private, so this snippet will fail to compile undercargo test --doc. Adjust the example to use only public APIs (similar to other examples in this module) or makenewpublic if exposing it is intended.
/// ```
/// use cot::auth::db::DatabaseUser;
/// use cot::common_types::Password;
/// # use cot::db::{Auto, LimitedString};
///
/// # let mut user = DatabaseUser::new(Auto::fixed(1), LimitedString::new("user").unwrap(), &Password::new("oldpassword"));
/// user.set_password(&Password::new("newpassword"));
/// ```
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1b071e6 to
ae1e533
Compare
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue or discussion
Description
This adds new methods to
DatabaseUserthat allow to set username and password for a user.Type of change