Skip to content

feat: add set_username and set_password to DatabaseUser#579

Open
m4tx wants to merge 3 commits into
masterfrom
database_user_methods
Open

feat: add set_username and set_password to DatabaseUser#579
m4tx wants to merge 3 commits into
masterfrom
database_user_methods

Conversation

@m4tx
Copy link
Copy Markdown
Member

@m4tx m4tx commented May 21, 2026

Related issue or discussion

Description

This adds new methods to DatabaseUser that allow to set username and password for a user.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / cleanup
  • Performance improvement
  • Other (describe above)

@m4tx m4tx requested review from ElijahAhianyo, Copilot and seqre May 21, 2026 13:50
@github-actions github-actions Bot added the C-lib Crate: cot (main library crate) label May 21, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

🐰 Bencher Report

Branchdatabase_user_methods
Testbedgithub-ubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark 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%)
🐰 View full continuous benchmarking report in Bencher

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 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_username to update the username field.
  • Added DatabaseUser::set_password to update the password field by hashing a provided Password.
  • 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_password also uses DatabaseUser::new(...), which is private, so this snippet will fail to compile under cargo test --doc. Adjust the example to use only public APIs (similar to other examples in this module) or make new public 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.

Comment thread cot/src/auth/db.rs
Comment thread cot/src/auth/db.rs Outdated
Comment thread cot/src/auth/db.rs Outdated
@m4tx m4tx force-pushed the database_user_methods branch from 1b071e6 to ae1e533 Compare May 21, 2026 14:07
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cot/src/auth/db.rs 50.00% 6 Missing and 2 partials ⚠️
Flag Coverage Δ
rust 90.29% <50.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot/src/auth/db.rs 82.57% <50.00%> (-2.52%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants