Repository navigation
Android: complete the 2FA login flow and fix unreadable login form in dark mode - #414
Merged
Merged
Conversation
added 2 commits
November 2, 2026 09:48
When an account has TOTP enabled the server answers the password login with
code 203 (CodeNotFullySuccess) and a 2FA session id in `data`, expecting a
follow-up POST /api/v4/session/token/2fa with {otp, session_id}. The app
treated every non-zero code as a failed login, so turning on 2FA locked
users out of the app entirely; the only way back in was the browser flow.
- Decode the login response's `data` as JsonElement, since it is either a
LoginResponse or the 2FA session id string.
- On 203, keep the session id in UI state and show a 6-digit code step.
- verify2FA() posts the code; a 404 means the ten-minute 2FA session
expired and returns the user to the password form.
- Back button abandons the challenge.
Nothing in the Compose tree painted a background: App() went CloudreveTheme -> NavHost -> LoginScreen -> Column with no Surface, so the window colour came from themes.xml, hard-coded to Theme.Material.Light, while CloudreveTheme followed the system and picked dark-scheme text colours. In dark mode that put light-grey text on a light window. - CloudreveTheme wraps content in a Surface painted with the scheme's background/onBackground, so Compose text always sits on Compose's own surface. - Set the full surface/background pairs with their on* colours in both schemes instead of overriding surface alone (every pair >= 4.5:1). - values-night/themes.xml gives the window a dark variant and a matching windowBackground, so the splash and edge-to-edge insets agree with the scheme too.
Mira PR WalkthroughThis PR implements two distinct Android fixes: (1) Completes the 2FA/TOTP login flow by handling the server's 203 response code, adding a 6-digit code entry step, and calling the verification endpoint; (2) Fixes dark mode readability by wrapping Compose content in a Surface with proper background/onBackground colors, and adding night theme XML resources so window background matches the Compose color scheme. Confidence: 4/5 ◉◉◉◉○ Safe with minor fixes
9 files reviewed
|
Open
Dvorinka
pushed a commit
that referenced
this pull request
Nov 5, 2026
#414 added a second companion object for the 2FA result codes, but the class already had one holding the OAuth constants. Kotlin allows only one per class, so compileDebugKotlin failed with "Only one companion object is allowed per class" and unresolved OAUTH_* references. Move the two constants into the existing companion object. Verified with ./gradlew :app:assembleDebug on JDK 21.
Dvorinka
added a commit
that referenced
this pull request
Nov 5, 2026
Android: fix compile error from duplicate companion object (#414 follow-up)
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.
Two Android login fixes, one commit each.
1. Complete the two-factor login flow
Enabling TOTP on an account locks the Android app out. With 2FA on, the server answers
POST /api/v4/session/tokenwithcode: 203(CodeNotFullySuccess) and the 2FA session id indata, expecting a follow-upPOST /api/v4/session/token/2fawith{otp, session_id}within ten minutes (routers/controllers/user.goUserLoginValidation,service/user/login.goVerify2FA). The app treated every non-zero code as a failed login, so the only way in was the browser OAuth flow, and nothing told the user that.Changes:
login()decodesdataasJsonElement, since it is either aLoginResponseor the 2FA session id string.203the session id is kept in UI state and the form switches to a 6-digit code step (TwoFactorStep), digits only, submit enabled at six.verify2FA()posts{otp, session_id}; success saves the session exactly as a plain login does.404means the ten-minute 2FA session expired and returns the user to the password form; any other error keeps the code step and shows the server message.The OAuth/browser sign-in and the refresh path are untouched.
2. Fix the unreadable login form in dark mode
The login form rendered light-grey text on a light background in dark mode. Nothing in the Compose tree painted a background:
App()goesCloudreveTheme → NavHost → LoginScreen → Columnwith noSurface/Scaffold, so the window colour came fromthemes.xml, hard-coded toTheme.Material.Light, whileCloudreveThemefollowed the system and picked the dark scheme's text colours. Text and background were coming from two themes that disagreed.Changes:
CloudreveThemewraps content in aSurfacepainted with the scheme'sbackground/onBackground, so Compose text always sits on Compose's own surface regardless of the window theme.background/surface/surfaceVariantpairs with theiron*colours andoutline, rather than overridingsurfacealone and inheriting defaults tuned for a different surface. Every text/background pair is ≥ 4.5:1 (WCAG AA);onSurfaceon dark surface is 14.6:1.values-night/themes.xml+values-night/colors.xmlgive the window a dark variant with a matchingwindowBackground, so the splash and edge-to-edge insets agree with the scheme too.Testing
Could not run a Gradle build in this environment (no Android SDK on the machine the fix was written on), so please run the usual build/lint. Logic was verified against the server contract in this repo; the contrast numbers were computed from the hex values.