Don't allow the creation of iCloud accounts if iCloud and iCloud Drive aren't enabled. Fixes #3106

This commit is contained in:
Maurice Parker 2021-06-17 19:05:39 -05:00
parent 7a28353358
commit d6aa5f23ba
2 changed files with 26 additions and 0 deletions

View File

@ -9,6 +9,14 @@
import Foundation
import Account
enum AccountsAddCloudKitWindowControllerError: LocalizedError {
case iCloudDriveMissing
var errorDescription: String? {
return NSLocalizedString("Unable to add iCloud Account. Please make sure you have iCloud and iCloud enabled in System Preferences.", comment: "Unable to add iCloud Account.")
}
}
class AccountsAddCloudKitWindowController: NSWindowController {
private weak var hostWindow: NSWindow?
@ -35,6 +43,11 @@ class AccountsAddCloudKitWindowController: NSWindowController {
}
@IBAction func create(_ sender: Any) {
guard FileManager.default.ubiquityIdentityToken != nil else {
NSApplication.shared.presentError(AccountsAddCloudKitWindowControllerError.iCloudDriveMissing)
return
}
let _ = AccountManager.shared.createAccount(type: .cloudKit)
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
}

View File

@ -9,6 +9,14 @@
import UIKit
import Account
enum CloudKitAccountViewControllerError: LocalizedError {
case iCloudDriveMissing
var errorDescription: String? {
return NSLocalizedString("Unable to add iCloud Account. Please make sure you have iCloud and iCloud enabled in System Preferences.", comment: "Unable to add iCloud Account.")
}
}
class CloudKitAccountViewController: UITableViewController {
weak var delegate: AddAccountDismissDelegate?
@ -31,6 +39,11 @@ class CloudKitAccountViewController: UITableViewController {
}
@IBAction func add(_ sender: Any) {
guard FileManager.default.ubiquityIdentityToken != nil else {
presentError(CloudKitAccountViewControllerError.iCloudDriveMissing)
return
}
let _ = AccountManager.shared.createAccount(type: .cloudKit)
dismiss(animated: true, completion: nil)
delegate?.dismiss()