Conversation
|
| Branch | is_active |
| 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,805.40 µs(+11.52%)Baseline: 6,102.49 µs | 7,699.78 µs (88.38%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 1,080.80 µs(+0.59%)Baseline: 1,074.49 µs | 1,323.73 µs (81.65%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 996.07 µs(+0.31%)Baseline: 993.03 µs | 1,204.49 µs (82.70%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 975.37 µs(+2.08%)Baseline: 955.50 µs | 1,167.97 µs (83.51%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 15,983.00 µs(-9.71%)Baseline: 17,701.50 µs | 21,171.80 µs (75.49%) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a persistent is_active flag for DatabaseUser and enforces it in the authentication flow so inactive users cannot log in (and won’t be restored from an existing session).
Changes:
- Added
is_active: booltoDatabaseUser, defaulting totrue, plus a setter and a small unit test. - Added a new DB migration to add the
is_activecolumn and registered it in the auth migrations list. - Updated auth logic to reject login for inactive users and to treat inactive session users as unauthenticated, with accompanying tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cot/src/auth/db/migrations/m_0002_add_is_active.rs | Adds a migration intended to introduce the is_active column. |
| cot/src/auth/db/migrations.rs | Registers the new migration in the auth migration list. |
| cot/src/auth/db.rs | Adds the is_active field to DatabaseUser, initializes it, and exposes a setter + test. |
| cot/src/auth.rs | Enforces is_active during login and when restoring a user from session; adds AuthError::UserInactive and tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+23
| &[::cot::db::migrations::Operation::add_field() | ||
| .table_name(::cot::db::Identifier::new("cot__database_user")) | ||
| .field( | ||
| ::cot::db::migrations::Field::new( | ||
| ::cot::db::Identifier::new("is_active"), | ||
| <bool as ::cot::db::DatabaseField>::TYPE, | ||
| ) | ||
| .set_null(<bool as ::cot::db::DatabaseField>::NULLABLE), | ||
| ) | ||
| .build()]; |
Comment on lines
+122
to
+129
| /// ``` | ||
| /// 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("password")); | ||
| /// user.set_is_active(false); | ||
| /// ``` |
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes 🚀 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.
Description
This adds an
is_activefield to the DatabaseUser and checks if user is active before allowing to sign in.Type of change