Skip to content

Fix QR login - #17900

Merged
alperozturk96 merged 1 commit into
masterfrom
fix/qrcode-login-when-no-enforced-servers
Oct 29, 2026
Merged

alperozturk96 merged 1 commit into
masterfrom
fix/qrcode-login-when-no-enforced-servers

Conversation

@daniele-verducci

@daniele-verducci daniele-verducci commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fix QR login when enforced servers are not defined

How to repro:

  • Use the default Nextcloud app with no enforced servers
  • On web, go to Settings -> Security -> App password
  • Create app password and click Show QR Code
  • Install app on device, click login button
  • Click QRcode icon under server address textfield
  • Scan the QR and click Yes when asked confirmation
  • The app reports "Server not allowed"

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>

if (enforcedServersJson.isEmpty()) {
return false
return true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If enforced servers list is not defined, the default should be true (= any server is allowed).
This was already present before the kotlin refactoring:

    private boolean checkAllowedServers(@NotNull String server) {
        String webviewLogin = getString(R.string.webview_login_url);

        if (!webviewLogin.isEmpty()) {
            if (webviewLogin.startsWith(server)) {
                return true;
            }
        }

        String enforcedServerList = getString(R.string.enforce_servers);

        if (!enforcedServerList.isEmpty()) {
            ArrayList<EnforcedServer> enforcedServers = new Gson().fromJson(enforcedServerList,
                                                                            new TypeToken<ArrayList<EnforcedServer>>() {
                                                                            }
                                                                                .getType());

            for (EnforcedServer enforcedServer : enforcedServers) {
                if (enforcedServer.getUrl().startsWith(server)) {
                    return true;
                }
            }
        }

        return false;    // <-- HERE
    }

@github-actions

Copy link
Copy Markdown

Codacy

SpotBugs

CategoryBaseNew
Bad practice2424
Correctness5147
Dodgy code148146
Experimental11
Malicious code vulnerability11
Multithreaded correctness2020
Performance2828
Security1515
Total288282

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...roid/authentication/server/EnforcedServerPolicy.kt 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit ee6fa54
Version 17900
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

@alperozturk96
alperozturk96 merged commit e85d31c into master Oct 29, 2026
28 of 35 checks passed
@alperozturk96
alperozturk96 deleted the fix/qrcode-login-when-no-enforced-servers branch October 29, 2026 06:12
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.

2 participants