Handle userId correctly in File Provider Extension client interface

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-09-30 16:05:30 +08:00
parent 6f1322fe47
commit 4d7b3eeacb
2 changed files with 7 additions and 5 deletions

View file

@ -104,12 +104,14 @@ extension FileProviderExtension: NSFileProviderServicing, ChangeNotificationInte
}
}
@objc func setupDomainAccount(user: String, serverUrl: String, password: String) {
@objc func setupDomainAccount(
user: String, userId: String, serverUrl: String, password: String
) {
let semaphore = DispatchSemaphore(value: 0)
var authAttemptState = AuthenticationAttemptResultState.connectionError // default
Task {
let authTestNcKit = NextcloudKit()
authTestNcKit.setup(user: user, userId: user, password: password, urlBase: serverUrl)
authTestNcKit.setup(user: user, userId: userId, password: password, urlBase: serverUrl)
// Retry a few times if we have a connection issue
for authTimeout in AuthenticationTimeouts {
@ -146,13 +148,13 @@ extension FileProviderExtension: NSFileProviderServicing, ChangeNotificationInte
)
}
let newNcAccount = Account(user: user, serverUrl: serverUrl, password: password)
let newNcAccount = Account(user: user, id: userId, serverUrl: serverUrl, password: password)
guard newNcAccount != ncAccount else { return }
ncAccount = newNcAccount
ncKit.setup(
account: newNcAccount.ncKitAccount,
user: newNcAccount.username,
userId: newNcAccount.username,
userId: newNcAccount.id,
password: newNcAccount.password,
urlBase: newNcAccount.serverUrl,
userAgent: "Nextcloud-macOS/FileProviderExt",

View file

@ -53,7 +53,7 @@ class FileProviderSocketLineProcessor: NSObject, LineProcessor {
let serverUrl = String(splitAccountDetails[2])
let password = String(splitAccountDetails[3])
delegate.setupDomainAccount(user: user, serverUrl: serverUrl, password: password)
delegate.setupDomainAccount(user: user, userId: userId, serverUrl: serverUrl, password: password)
}
}
}