Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track logged-in user and change password #913

Merged
merged 13 commits into from
Jan 30, 2025
Merged

Track logged-in user and change password #913

merged 13 commits into from
Jan 30, 2025

Conversation

marlonbaeten
Copy link
Contributor

@marlonbaeten marlonbaeten commented Jan 27, 2025

Adds user state to the ApiProvider and implement a change-password form.

#858 should me merged first

Fixes #712
Fixes #907

To Test:

# run the backend
cd backend
sqlx database reset
cargo run -- --reset-database --seed-data

# run the frontend
cd frontend
npm run dev:server

Or visit https://abacus-test.nl. Note that changing a password updates the database entry, changes to a abacus-test instance are persisted (and you might not be able to login if someone else did a password change). You can always sartup a new instance.

Go to /account/login and login using "user" and "password", then go to /account/change-password and change the password. Try logging in with the new password on /account/login.

Copy link

github-actions bot commented Jan 27, 2025

Sigrid maintainability feedback

✅ You wrote maintainable code and achieved your objective of 3.5 stars

Show details

Sigrid compared your code against the baseline of 2025-01-30.

👍 What went well?

You fixed or improved 0 refactoring candidates.

👎 What could be better?

Unfortunately, 13 refactoring candidates were introduced or got worse.

Risk System property Location
🔴 Duplication
(Introduced)
backend/src/authentication/user.rs (lines 195-203)
backend/src/authentication/user.rs (lines 216-224)
🔴 Duplication
(Introduced)
frontend/lib/api/ApiError.ts (lines 18-25)
frontend/lib/api/ApiError.ts (lines 31-37)
🔴 Unit Size
(Worsened)
backend/src/error.rs
IntoResponse.into_response()
🔴 Unit Size
(Worsened)
backend/src/lib.rs
router(SqlitePool)
🟠 Unit Size
(Worsened)
frontend/app/routes.tsx
routes.tsx
🟠 Module Coupling
(Worsened)
frontend/lib/api/ApiError.ts
🟡 Unit Size
(Introduced)
frontend/lib/api/useSessionState.ts
useSessionState.ts.useSessionState(boolean)
🟡 Unit Size
(Introduced)
frontend/app/component/form/user/change_password/ChangePasswordForm.tsx
handleSubmit(FormEvent<HTMLFormElement>)
⚫️ + 5 more

📚 Remaining technical debt

14 refactoring candidates didn't get better or worse, but are still present in the code you touched.

View this system in Sigrid** to explore your technical debt

⭐️ Sigrid ratings

System property System on 2025-01-30 Before changes New/changed code
Volume 5.2 N/A N/A
Duplication 4.3 4.6 4.8
Unit Size 2.4 1.9 2.2
Unit Complexity 3.4 4.7 4.7
Unit Interfacing 2.9 4.4 4.3
Module Coupling 4.0 4.6 4.4
Component Independence 2.8 N/A N/A
Component Entanglement 3.6 N/A N/A
Maintainability 3.6 4.1 4.1

💬 Did you find this feedback helpful?

We would like to know your thoughts to make Sigrid better.
Your username will remain confidential throughout the process.


View this system in Sigrid

cikzh
cikzh previously approved these changes Jan 28, 2025
Copy link
Contributor

@cikzh cikzh left a comment

Choose a reason for hiding this comment

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

Focused mainly on backend code

Lionqueen94
Lionqueen94 previously approved these changes Jan 28, 2025
Copy link

codecov bot commented Jan 30, 2025

Bundle Report

Changes will increase total bundle size by 8.37kB (0.44%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
abacus-frontend-esm 1.9MB 8.37kB (0.44%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: abacus-frontend-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/app-*.js 8.37kB 711.01kB 1.19%

Files in assets/app-*.js:

  • ./lib/api/ApiProviderContext.tsx → Total Size: 60 bytes

  • ./app/module/account/page/ChangePasswordPage.tsx → Total Size: 832 bytes

  • ./lib/api/ApiClient.ts → Total Size: 5.13kB

  • ./lib/api/useSessionState.ts → Total Size: 672 bytes

  • ./lib/i18n/locales/nl/user.json → Total Size: 2.0kB

  • ./lib/api/useApi.ts → Total Size: 208 bytes

  • ./app/module/DevHomePage.tsx → Total Size: 4.19kB

  • ./app/component/form/user/change_password/ChangePasswordForm.tsx → Total Size: 4.34kB

  • ./lib/api/ApiProvider.tsx → Total Size: 562 bytes

  • ./lib/i18n/locales/nl/error.json → Total Size: 2.62kB

  • ./lib/api/useApiState.ts → Total Size: 203 bytes

  • ./app/component/form/user/login/LoginForm.tsx → Total Size: 2.29kB

  • ./lib/api/ApiError.ts → Total Size: 1.53kB

  • ./app/routes.tsx → Total Size: 4.97kB

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 92.24806% with 30 lines in your changes missing coverage. Please review.

Project coverage is 86.66%. Comparing base (9cb7092) to head (fd87900).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
backend/src/authentication/mod.rs 88.88% 5 Missing and 2 partials ⚠️
...t/form/user/change_password/ChangePasswordForm.tsx 94.69% 6 Missing ⚠️
frontend/lib/api/useUser.ts 33.33% 6 Missing ⚠️
backend/src/authentication/user.rs 93.33% 1 Missing and 1 partial ⚠️
frontend/app/module/DevHomePage.tsx 0.00% 2 Missing ⚠️
frontend/lib/api/ApiProvider.tsx 90.47% 2 Missing ⚠️
frontend/lib/api/useApiState.ts 77.77% 2 Missing ⚠️
frontend/lib/api/useSessionState.ts 92.85% 2 Missing ⚠️
backend/src/error.rs 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #913      +/-   ##
==========================================
+ Coverage   85.61%   86.66%   +1.05%     
==========================================
  Files         225      263      +38     
  Lines        8933    13480    +4547     
  Branches     1147     1297     +150     
==========================================
+ Hits         7648    11683    +4035     
- Misses       1285     1703     +418     
- Partials        0       94      +94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marlonbaeten marlonbaeten added this pull request to the merge queue Jan 30, 2025
Merged via the queue into main with commit 30660d6 Jan 30, 2025
21 checks passed
@marlonbaeten marlonbaeten deleted the change-password branch January 30, 2025 15:39
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.

Store logged-in user in frontend Implement change password endpoint
4 participants