Skip to content

feat: Add securityScore and lastPasswordUpdate in AccountEntity#149

Merged
tevincent merged 16 commits intomainfrom
save-score-last-updated-password
May 6, 2026
Merged

feat: Add securityScore and lastPasswordUpdate in AccountEntity#149
tevincent merged 16 commits intomainfrom
save-score-last-updated-password

Conversation

@tevincent
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 30, 2026 06:32
Copy link
Copy Markdown

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 extends the account persistence model to store security-related profile metadata (security score + last password update) and adds a refresh pathway to re-sync that metadata from the backend, including a UI-triggered refresh from the account list.

Changes:

  • Add securityScore and lastPasswordUpdate fields to AccountEntity and update persistence calls to populate them from UserProfile.preferences.security.
  • Add a new AuthenticatorFacade.refreshUserProfileFor(...) API and wire it through AuthenticatorFacadeImpl.
  • Add an account-list refresh hook to trigger user-profile syncing from the app UI.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
multiplatform-lib/src/commonMain/kotlin/models/migration/user/preferences/Preferences.kt Makes Preferences.security non-null (now required) for profile parsing.
multiplatform-lib/src/commonMain/kotlin/internal/db/AccountsDao.kt Makes getAccountsWith suspend and adds getAccount for one-shot reads.
multiplatform-lib/src/commonMain/kotlin/internal/db/AccountEntity.kt Adds securityScore and lastPasswordUpdate columns to the entity.
multiplatform-lib/src/commonMain/kotlin/internal/AuthenticatorFacadeImpl.kt Fetches/stores security fields from user profile; adds syncing helper and refresh entrypoint.
multiplatform-lib/src/commonMain/kotlin/DummyAuthenticatorFacade.kt Adds stub implementation for the new facade method.
multiplatform-lib/src/commonMain/kotlin/AuthenticatorFacade.kt Adds new abstract API refreshUserProfileFor(...).
multiplatform-lib/schemas/com.infomaniak.auth.lib.internal.db.AccountsDatabase/1.json Updates exported Room schema to include new columns.
app/src/main/kotlin/com/infomaniak/auth/ui/screen/accountlist/AccountListViewModel.kt Adds refreshUserProfiles() and nests AccountListUiState in the VM.
app/src/main/kotlin/com/infomaniak/auth/ui/screen/accountlist/AccountListScreen.kt Wires pull-to-refresh to also refresh user profiles.
Comments suppressed due to low confidence (1)

multiplatform-lib/src/commonMain/kotlin/internal/AuthenticatorFacadeImpl.kt:346

  • After syncAccountWithUserProfile(...) updates the account row with securityScore/lastPasswordUpdate, the subsequent dao.upsert(notConnectedAccount.copy(status = LoggedIn)) can overwrite those new columns with the (likely default) values from notConnectedAccount. Consider including the security fields in that final upsert, or avoid the second upsert if syncAccountWithUserProfile already persisted the needed updates.
                val userProfile = syncAccountWithUserProfile(apiToken.accessToken, userId)
                userProfile.apiToken = apiToken
                authenticatorBridge.persistUserProfile(userProfile)
            },
        )

        if (succeeded.not()) return false

        dao.upsert(notConnectedAccount.copy(status = AccountEntity.Status.LoggedIn))


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread multiplatform-lib/src/commonMain/kotlin/internal/AuthenticatorFacadeImpl.kt Outdated
@tevincent tevincent force-pushed the save-score-last-updated-password branch 4 times, most recently from 814e241 to 7c3f061 Compare April 30, 2026 08:52
@tevincent tevincent marked this pull request as draft April 30, 2026 11:07
@tevincent tevincent marked this pull request as ready for review May 1, 2026 11:01
@tevincent tevincent force-pushed the save-score-last-updated-password branch 2 times, most recently from ce5ebfb to 7cb8a06 Compare May 1, 2026 11:03
tevincent and others added 14 commits May 6, 2026 15:19
# Conflicts:
#	multiplatform-lib/src/commonMain/kotlin/internal/db/AccountsDao.kt

# Conflicts:
#	multiplatform-lib/src/commonMain/kotlin/models/migration/user/preferences/Preferences.kt
…og when an Account's password has been updated
# Conflicts:
#	app/src/main/kotlin/com/infomaniak/auth/ui/screen/main/MainScreen.kt
Account.Status.LoggedIn changes:
- Becomes a class (no longer an object)
- Add the securityScore property and use it
- Add the passwordChangedAck property

AuthenticatorFacade changes:
- Replaces refreshUserProfileFor(…) with refreshUserProfiles()
- Make the addAccounts function accept SharedUserProfile instead of Account

AuthenticatorFacadeImpl changes:
- Report non-retriable errors (and separate it from the toIssueCause() conversion function
- Replace accountsToLogin with userIdsToStatusFlows
- Replace loginAttemptsFlow with accountStatusForUser
- Make the accountStatusForUser function handle profile updates of logged-in accounts
@tevincent tevincent force-pushed the save-score-last-updated-password branch from 237941f to 3621a83 Compare May 6, 2026 13:20
@tevincent tevincent enabled auto-merge May 6, 2026 13:22
@tevincent tevincent force-pushed the save-score-last-updated-password branch from 23529c7 to d78a146 Compare May 6, 2026 13:26
@tevincent tevincent force-pushed the save-score-last-updated-password branch from 0f53ae0 to ba42ed7 Compare May 6, 2026 13:49
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@tevincent tevincent merged commit 23b4379 into main May 6, 2026
9 checks passed
@tevincent tevincent deleted the save-score-last-updated-password branch May 6, 2026 13:58
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