From 75335bc33d1f6d430cba06b8cd738bb0af074d1b Mon Sep 17 00:00:00 2001 From: vlad Date: Thu, 19 Nov 2026 10:01:27 +0100 Subject: [PATCH] fix(auth): show the sign-in error instead of closing the screen The server can accept the credentials, and the app can still refuse to save the account. This happens in two cases: - An account with the same user and server already exists on the device (ACCOUNT_NOT_NEW). - An existing account signs in again, and the server returns another user ID than the one of the account (ACCOUNT_NOT_THE_SAME). In both cases, onCredentialsAccepted() shows the server address form again, and puts the message under the address field. In the standard build, the person never saw that message. updateAuthStatus() treats both results as fatal when showWebViewLoginUrl is false. This flag is false in every build that has no branded web login URL. For a fatal result, updateAuthStatus() shows the message in a snackbar and closes the activity. The snackbar belongs to the closing activity, so it disappears at once. The person saw the address form again, or saw the sign-in screen close, without any explanation. The activity is meant to close only in a build that has no address field for the message. Pull request 5061 of the upstream repository introduced this behavior. It read the flag from show_server_url_input in every build, and it showed the message in a Toast. - The server address login now sets showWebViewLoginUrl, because this login always shows the address field. The activity stays open and shows the message. - The builds that still close the activity show the message in a Toast. A Toast stays visible after the activity closes. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 --- .../android/authentication/AuthenticatorActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.kt b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.kt index e829b39be8e8..ce9e19578866 100644 --- a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.kt +++ b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.kt @@ -61,6 +61,7 @@ import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.repository.ClientRepository import com.nextcloud.utils.SnackbarUtil import com.nextcloud.utils.extensions.getParcelableArgument +import com.nextcloud.utils.extensions.showToast import com.nextcloud.utils.mdm.MDMConfig import com.nextcloud.utils.text.LinkFormatter import com.owncloud.android.MainApp @@ -412,6 +413,8 @@ open class AuthenticatorActivity : } private fun initServerUrlLogin(savedInstanceState: Bundle?) { + // errors are shown under the address field, so updateAuthStatus() must keep the activity open + showWebViewLoginUrl = true val binding = inflateAccountSetupLayout() initOverallUi(binding) @@ -843,7 +846,8 @@ open class AuthenticatorActivity : authStatus = statusMapper.forAuthentication(result, isHostUrlPlainHttp, showWebViewLoginUrl, authStatus.text) if (!showWebViewLoginUrl && statusMapper.isFatalAuthenticationError(result)) { - SnackbarUtil.show(this, authStatus.text) + // a snackbar would close together with the finishing activity + authStatus.text?.let { applicationContext.showToast(it) } finish() } }