Skip to content

feat: Migration of legacy accounts#83

Open
tevincent wants to merge 15 commits intomainfrom
detect-migration-needed
Open

feat: Migration of legacy accounts#83
tevincent wants to merge 15 commits intomainfrom
detect-migration-needed

Conversation

@tevincent
Copy link
Copy Markdown
Contributor

No description provided.

@Infomaniak Infomaniak deleted a comment from github-actions bot Mar 26, 2026
@Infomaniak Infomaniak deleted a comment from github-actions bot Mar 26, 2026
@Infomaniak Infomaniak deleted a comment from github-actions bot Mar 26, 2026
@tevincent tevincent force-pushed the detect-migration-needed branch from f34e098 to 127c1dc Compare March 26, 2026 14:37
@tevincent tevincent marked this pull request as ready for review March 26, 2026 14:37
@tevincent tevincent force-pushed the detect-migration-needed branch from 127c1dc to ecc900f Compare March 26, 2026 14:47
# Conflicts:
#	app/build.gradle.kts
#	gradle/libs.versions.toml

wip

wip

# Conflicts:
#	multiplatform-lib/src/commonMain/kotlin/AuthenticatorFacade.kt
#	multiplatform-lib/src/commonMain/kotlin/internal/AuthenticatorFacadeImpl.kt
#	multiplatform-lib/src/commonMain/kotlin/internal/managers/MigrationManager.kt

wip

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

# Conflicts:
#	app/build.gradle.kts
@Infomaniak Infomaniak deleted a comment from github-actions bot Mar 27, 2026
@Infomaniak Infomaniak deleted a comment from github-actions bot Mar 27, 2026
@Infomaniak Infomaniak deleted a comment from github-actions bot Mar 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

PR Reviewer Guide 🔍

(Review updated until commit 20c0f23)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Hardcoded Staging Environment

The AuthenticatorFacade.create() call hardcodes environment = ApiEnvironment.Staging. This appears to be debug code that should use a build configuration or environment variable to support production releases. If deployed as-is, all authentication requests will hit staging servers instead of production.

environment = ApiEnvironment.Staging,
Runtime Crash from TODO

Line 234 contains TODO("Try to login with credentials and OTP (native login)") passed as a parameter to attemptMigration. The Kotlin TODO() function throws NotImplementedError, which will crash the app if this code path is executed during a migration scenario.

attemptMigration(accountToMigrate, TODO("Try to login with credentials and OTP (native login)"))
Singleton Database Lifecycle Issue

getLegacyAccounts() closes the database in a finally block after reading. Since OTPUserDatabase is a singleton (via INSTANCE), subsequent calls to getInstance() will return the already-closed instance, causing crashes if the migration flow or any other code attempts to access legacy accounts again. Consider removing the close operation or using a non-singleton pattern if the database is truly only needed once.

return withContext(Dispatchers.IO) {
    try {
        database.otpUserDao().getAllUsers().map {
            LegacyAccount(
                userId = it.userID,
                email = it.email,
                displayName = it.displayName,
                avatar = it.avatar,
                secret = it.secret
            )
        }
    } finally {
        database.close()
    }
}

@github-actions
Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 20c0f23

Comment on lines +125 to 131
return AuthenticatorFacade.create(
environment = ApiEnvironment.Staging,
userAgent = userAgent,
clientId = BuildConfig.CLIENT_ID,
crashReport = crashReport,
tokenBridge = tokenBridge,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: The API environment is hardcoded to Staging, which will cause production builds to use staging servers. Inject the environment based on build configuration (e.g., BuildConfig.DEBUG) or a configurable property to ensure production releases use the correct endpoint. [possible issue, importance: 9]

Suggested change
return AuthenticatorFacade.create(
environment = ApiEnvironment.Staging,
userAgent = userAgent,
clientId = BuildConfig.CLIENT_ID,
crashReport = crashReport,
tokenBridge = tokenBridge,
)
return AuthenticatorFacade.create(
environment = if (BuildConfig.DEBUG) ApiEnvironment.Staging else ApiEnvironment.Production,
userAgent = userAgent,
clientId = BuildConfig.CLIENT_ID,
crashReport = crashReport,
tokenBridge = tokenBridge,
)

@sonarqubecloud
Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant