From 27a311260a90ab972da78a4f1f3e2432b531bc17 Mon Sep 17 00:00:00 2001 From: Dixit Sabharwal Date: Wed, 4 Nov 2026 21:20:25 +0100 Subject: [PATCH 1/2] android: merge duplicate companion object in LoginViewModel #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. --- .../org/cloudreve/android/ui/login/LoginViewModel.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt b/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt index 67833d3687..7c5ad98ab3 100644 --- a/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt +++ b/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt @@ -33,13 +33,6 @@ class LoginViewModel( private val api: ApiClient, ) : ViewModel() { - private companion object { - /** serializer.CodeNotFullySuccess: password accepted, 2FA code still required. */ - const val CODE_NOT_FULLY_SUCCESS = 203 - /** serializer.CodeNotFound: here, the 2FA session expired. */ - const val CODE_NOT_FOUND = 404 - } - private val _state = MutableStateFlow(LoginUiState()) val state: StateFlow = _state @@ -202,6 +195,11 @@ class LoginViewModel( .trim() companion object { + /** serializer.CodeNotFullySuccess: password accepted, 2FA code still required. */ + private const val CODE_NOT_FULLY_SUCCESS = 203 + /** serializer.CodeNotFound: here, the 2FA session expired. */ + private const val CODE_NOT_FOUND = 404 + // Built-in public OAuth client (seeded by the server migration). private const val OAUTH_CLIENT_ID = "393a1839-f52e-498e-9972-e77cc2241eee" private const val OAUTH_REDIRECT = "/callback/desktop" From 6f2ce652206933a1f17bee8bbed4fe58c62e79ee Mon Sep 17 00:00:00 2001 From: Dixit Sabharwal Date: Wed, 4 Nov 2026 21:37:32 +0100 Subject: [PATCH 2/2] android: request only the scopes the Desktop OAuth client is granted "Sign in with browser" failed with "Invalid scope requested": the app uses the built-in Desktop client, whose seeded scopes do not include UserSecurityInfo.Write (only the iOS client has it), and the server requires requested scopes to be a subset of the client's. The app calls no endpoint guarded by that scope, so drop it. --- .../main/java/org/cloudreve/android/ui/login/LoginViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt b/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt index 7c5ad98ab3..c7edf73aba 100644 --- a/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt +++ b/android/app/src/main/java/org/cloudreve/android/ui/login/LoginViewModel.kt @@ -204,6 +204,6 @@ class LoginViewModel( private const val OAUTH_CLIENT_ID = "393a1839-f52e-498e-9972-e77cc2241eee" private const val OAUTH_REDIRECT = "/callback/desktop" private const val OAUTH_SCOPES = - "profile email openid offline_access UserInfo.Write UserSecurityInfo.Write Workflow.Write Files.Write Shares.Write" + "profile email openid offline_access UserInfo.Write Workflow.Write Files.Write Shares.Write" } }