Skip to content

feat: account setup in SwiftUI with the shared NextcloudKitUI onboarding and login - #4493

Merged
mpivchev merged 33 commits into
masterfrom
shared-login
Nov 26, 2026
Merged

mpivchev merged 33 commits into
masterfrom
shared-login

Conversation

@mpivchev

@mpivchev mpivchev commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Replaces the UIKit login, intro and provider sign-up with NextcloudKitUI's shared onboarding and login, so the whole account setup is SwiftUI.

Uses NextcloudKit 7.7.0, which contains nextcloud/NextcloudKit#278.

What changes

  • Onboarding: NextcloudKitUI's OnboardingView replaces the Brand/Intro carousel. It shows once, before the first login, unless disable_intro is set.
  • Login: ServerAddressView with the brand colors, QR code login, accounts from other apps, and — unless disable_intro is set — "Sign up with a provider" and "Host your own server".
  • Provider sign-up: an in-app page from NextcloudKitUI; refused sign-up credentials restart the login, as on Android.
  • App side: NCAccountSetupView + NCAccountSetupModel (@Observable) in a plain UIHostingController. They handle branding, the managed configuration (including auto-login), the certificate trust and http prompts, and account creation.
  • Removed: NCLogin, NCLoginProvider, NCLoginQRCode, NCShareAccounts, Brand/Intro, the intro images and their unused strings. The QRCodeReader package goes too; NextcloudKitUI scans with CodeScanner.
  • The onboarding and login stay in portrait on iPhone.

Unchanged behavior

  • Brand and MDM options (NCBrandOptions), enforce_servers, disable_request_login_url, loginBaseUrl.
  • Untrusted certificate prompt with certificate details; the https → http fallback asks first in Release builds.

Tests

  • New NCAccountSetupModelTests; UI tests use the continueOnboarding identifier and accept the login without the onboarding.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

🤖 Generated with Claude Code

mpivchev and others added 24 commits November 19, 2026 16:59
Temporary: points NextcloudKit and NextcloudKitUI at the sibling
worktree. Swap back to a tagged NextcloudKit release before merging.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
NCLoginHostingController shows NextcloudKitUI's ServerAddressView. Its
NCLoginCoordinator maps the brand and MDM options to the login
configuration, offers the untrusted-certificate and http fallback
prompts, runs the managed-configuration auto-login, lists accounts of
other Nextcloud apps and creates the account. NCProviderSignUp handles
signing up with a provider through the login callback URL.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Add the login sources to the Nextcloud target and Login group, and the
tests to NextcloudUnitTests, instead of Action Assistant and
NextcloudUITests.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Every login entry point (window root, add-account modal, Intro push)
now shows NCLoginHostingController. NCAccount.createAccount throws
instead of presenting its own alert, so the login view can show the
error and stay usable.

Remove the old login screens (NCLogin, NCLoginProvider, NCLoginQRCode,
NCShareAccounts), the QRCodeReader package, the unused client
certificate delegate, the login-flow v2 state in AppDelegate and the
English strings only they used.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Accounts of other apps are not suggested while the managed
configuration logs in by itself, because their sheet would keep the
login screen from closing. Managed server and user values are trimmed,
and an invalid server address shows an error instead of doing nothing.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
The shared accounts file kept a removed account until the next export,
so the login shown right after removing it offered that account again.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
The override only applied when the login was pushed from the intro, as
the embedded navigation stack decides otherwise. The old login used the
default style too.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Signing up with a provider ended on the provider's web home screen. The
sign-up page only returns the app login URL to page loads that carry the
OCS API header, which a browser session cannot send. Show the sign-up in
a web view that sends the header and the app user agent, as before the
browser session, and add the account from the nc://login/ URL it ends on.

nextcloud.com caches the sign-up page without regard to the header, so
the first load adds a query to get a fresh page.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
The sign-up web view stayed blank when the page failed to load, for
example while nextcloud.com is unreachable. It now shows the error with
Retry and Close. Loads the web view replaces itself are not reported.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
The QR code scanner now stays open while its code logs in. The login
is dismissed from its presenter so the scanner sheet closes with it,
and a login replaced as the window root dismisses what it still shows.
Only a sheet that is already closing is waited for before adding the
account.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
The sign-up page could end on a blank screen without an error: a dead
server only showed a spinner for a minute, the spinner vanished after
the first redirect, HTTP error pages loaded as if they were fine, and a
connection refused while the screen slid in dropped its alert.

The first load now starts once the screen is shown, loads give up after
20 seconds without data, error responses and empty or unshowable pages
show NextcloudKit's readable message, and the screen keeps its own
spinner while loading. Retry loads the page that failed, a redirect
loop ends in an error, a crashed web content process reloads once, and
errors after the sign-up completes show in the sign-up's own window.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
…nother page

A reply that is no profile, such as the login page of a proxy, has no
error kind, so the sign-up and managed configuration banners showed
nothing. It is now reported as an invalid response.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
…or the host is unknown

Without a network or with a mistyped host name, the login offered to
retry over insecure http, saying a secure connection had failed. Plain
http can't help in those cases, so NextcloudKit's readable message is
shown instead. Other https failures still offer the fallback, which is
how http-only servers are reached.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
The managed configuration and provider sign-up banners said "The file
or folder could not be found on the server." for a 404 while adding the
account. A new login error context titles them "Couldn't log in" and
words a 404 as "No server was found at this address."; other errors
keep NextcloudKit's readable message. A kind-less reply to the app
password request is reported as an invalid response instead of nothing.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
…edentials

Providers running the current preferred_providers app hand over a
temporary session token after the sign-up, which Nextcloud 33 refuses,
so adding the account failed with 401. The sign-up now opens the login
for the provider's server and starts it right away, so the user logs in
to the new account in the browser and the app gets a lasting app
password. The managed configuration auto-login doesn't run there.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
…he intro

The override applies to the whole app, so it lives with the other
navigation controller extensions before the intro goes away.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
NextcloudKitUI's onboarding replaces the intro carousel, and its login
offers signing up with a provider and hosting a server, unless the brand
disables the intro. One SwiftUI view and its model replace the intro,
the login hosting controller, the login coordinator and the UIKit
sign-up page. The certificate and insecure connection prompts are
SwiftUI alerts.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
The app delegate allows only portrait while the account setup is shown,
including the pages it presents, and the Info.plist orientations
otherwise.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Continuing the onboarding is remembered in the preferences, so later launches without an account open the login directly. UI tests accept either screen.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>

# Conflicts:
#	Nextcloud.xcodeproj/project.pbxproj
#	Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Replaces the local package reference with the branch of nextcloud/NextcloudKit#278, so CI can build this. Switch to a release once that is merged.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
mpivchev and others added 5 commits November 26, 2026 10:37
Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Fold the managed auto-login error banners into one do/catch, set onCancel only
when the cancel button should show (NextcloudKit drops showsCancelButton),
replace the certificate details delegate and coordinator with an onClose
closure, drop the unused intro selector constants and NCAccount.appDelegate,
fix the stale transition comment and merge the cancelled classifier test into
the unreachable cases.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Adding an account copied the last certificate the server presented into the trusted ones. A second QR code scan for a server with an untrusted certificate was therefore trusted without asking. Certificates are now trusted only from the certificate prompt.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
mpivchev and others added 2 commits November 26, 2026 12:44
…ogins

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
7.7.0 contains the shared onboarding, login and provider sign-up of nextcloud/NextcloudKit#278.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
@mpivchev
mpivchev marked this pull request as ready for review November 26, 2026 12:01
Copilot AI balanced review requested due to automatic review settings November 26, 2026 12:01
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>

# Conflicts:
#	Nextcloud.xcodeproj/project.pbxproj

Copilot AI left a comment

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.

🟡 Changes recommended

Account setup can disclose an existing account’s client certificate and proof of possession to unrelated servers, while missing certificate-import and password handling blocks fresh installs from adding certificate-protected servers.

2 open issues
What changed in this PR

Migrates account setup to SwiftUI using NextcloudKitUI’s shared onboarding and login, replacing the app’s UIKit implementation.

Changes:

  • Adds a setup view and model for branding, managed login, certificate prompts and account creation.
  • Updates account-entry points, onboarding persistence, login errors and tests.
  • Pins NextcloudKit to 7.7.0 and removes obsolete screens, assets and QRCodeReader dependencies.
File Description
Tests/​NextcloudUnitTests/​NKErrorUserFriendlyMessageTests.swift Tests login-specific error messages.
Tests/​NextcloudUnitTests/​NCLoginServerErrorClassifierTests.swift Tests certificate and HTTP recovery classification.
Tests/​NextcloudUnitTests/​NCLoginAppConfigTests.swift Tests managed login configuration.
Tests/​NextcloudUnitTests/​NCAccountSetupModelTests.swift Tests certificate prompt handling.
Tests/​NextcloudUITests/​PasscodeUITests.swift Accepts the new setup screens after reset.
Tests/​NextcloudUITests/​BaseUIXCTestCase.swift Updates onboarding and login detection.
Nextcloud.xcodeproj/​project.xcworkspace/​xcshareddata/​swiftpm/​Package.resolved Pins NextcloudKit and removes QRCodeReader.
Nextcloud.xcodeproj/​project.pbxproj Registers new sources and removes legacy dependencies.
iOSClient/​Supporting Files/​en.lproj/​Localizable.strings Adds setup messages and removes unused strings.
iOSClient/​Settings/​NCPreferences.swift Stores onboarding completion.
iOSClient/​Settings/​Acknowledgements.rtf Removes QRCodeReader acknowledgement.
iOSClient/​SceneDelegate.swift Launches the SwiftUI setup.
iOSClient/​Networking/​NKError+UserFriendlyMessage.swift Adds login-specific 404 wording.
iOSClient/​Networking/​NCNetworking.swift Removes client-certificate UI callbacks.
iOSClient/​Networking/​NCErrorContext.swift Adds login error context.
iOSClient/​NCGlobal.swift Removes obsolete intro selectors.
iOSClient/​Login/​NCViewCertificateDetails.swift Replaces dismissal delegate with a closure.
iOSClient/​Login/​NCLoginServerErrorClassifier.swift Classifies login recovery options.
iOSClient/​Login/​NCLoginQRCode.swift Removes the legacy QR scanner.
iOSClient/​Login/​NCLoginProvider.swift Removes the legacy browser login implementation.
iOSClient/​Login/​NCLoginAppConfig.swift Extracts managed configuration parsing.
iOSClient/​Login/​NCLogin.swift Removes the UIKit login controller.
iOSClient/​Login/​NCLogin.storyboard Removes the UIKit login layout.
iOSClient/​Login/​NCAccountSetupView.swift Hosts shared onboarding, login and prompts.
iOSClient/​Login/​NCAccountSetupModel.swift Coordinates setup configuration and account creation.
iOSClient/​Images.xcassets/​certificate.imageset/​Contents.json Removes unused certificate asset metadata.
iOSClient/​Images.xcassets/​certificate.imageset/​certificate.svg Removes the unused certificate icon.
iOSClient/​GUI/​Lucid Banner/​AlertActionBannerView.swift Removes the obsolete account-discovery banner.
iOSClient/​Files/​NCFilesNavigationController.swift Presents SwiftUI setup when adding accounts.
iOSClient/​Files/​NCFiles.swift Shows setup when no accounts remain.
iOSClient/​Extensions/​UINavigationController+Extension.swift Relocates existing status-bar forwarding.
iOSClient/​Extensions/​UIButton+Extension.swift Removes obsolete login spinner helpers.
iOSClient/​AppDelegate.swift Updates certificate callbacks and setup orientation handling.
iOSClient/​Account/​NCAccount.swift Propagates creation errors and updates setup transitions.
iOSClient/​Account/​Account Request/​NCShareAccounts.swift Removes the legacy shared-account picker.
iOSClient/​Account/​Account Request/​NCShareAccounts.storyboard Removes the shared-account picker layout.
Brand/​Intro/​NCIntroViewController.swift Removes the UIKit intro carousel.
Brand/​Intro/​NCIntroCollectionViewCell.xib Removes the intro cell layout.
Brand/​Intro/​NCIntroCollectionViewCell.swift Removes the intro cell implementation.
Brand/​Intro/​NCIntro.storyboard Removes the intro screen layout.
Brand/​Custom.xcassets/​intro4.imageset/​Contents.json Removes intro asset metadata.
Brand/​Custom.xcassets/​intro3.imageset/​Contents.json Removes intro asset metadata.
Brand/​Custom.xcassets/​intro2.imageset/​Contents.json Removes intro asset metadata.
Brand/​Custom.xcassets/​intro1.imageset/​intro1.svg Removes the legacy intro illustration.
Brand/​Custom.xcassets/​intro1.imageset/​Contents.json Removes intro asset metadata.
AGENTS.md Updates the branding directory description.

Review effort: Balanced

func loginDidAppear() {
guard !hasLoginAppeared else { return }

hasLoginAppeared = true
let cert = (p12Data, self.p12Password) as? UserCertificate,
let pkcs12 = try? PKCS12(pkcs12Data: cert.data, password: cert.password, onIncorrectPassword: {
self.certificateDelegate?.onIncorrectPassword()
nkLog(error: "The client certificate password is incorrect.")
# Conflicts:
#	Nextcloud.xcodeproj/project.pbxproj
@mpivchev
mpivchev merged commit 267a45e into master Nov 26, 2026
5 checks passed
@mpivchev
mpivchev deleted the shared-login branch November 26, 2026 13:35
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