diff --git a/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift b/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift index 5f2e2081b..5b84ce7af 100644 --- a/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift @@ -56,7 +56,7 @@ class AccountsFeedWranglerWindowController: NSWindowController { return } - guard !AccountManager.shared.duplicateServiceAccount(type: .feedWrangler, username: usernameTextField.stringValue) else { + guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: .feedWrangler, username: usernameTextField.stringValue) else { self.errorMessageLabel.stringValue = NSLocalizedString("There is already a FeedWrangler account with that username created.", comment: "Duplicate Error") return } diff --git a/Mac/Preferences/Accounts/AccountsNewsBlurWindowController.swift b/Mac/Preferences/Accounts/AccountsNewsBlurWindowController.swift index 723e254d1..e3fc527b2 100644 --- a/Mac/Preferences/Accounts/AccountsNewsBlurWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsNewsBlurWindowController.swift @@ -56,7 +56,7 @@ class AccountsNewsBlurWindowController: NSWindowController { return } - guard !AccountManager.shared.duplicateServiceAccount(type: .newsBlur, username: usernameTextField.stringValue) else { + guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: .newsBlur, username: usernameTextField.stringValue) else { self.errorMessageLabel.stringValue = NSLocalizedString("There is already a NewsBlur account with that username created.", comment: "Duplicate Error") return } diff --git a/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift b/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift index 66a286151..ccec1dedd 100644 --- a/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift @@ -91,7 +91,7 @@ class AccountsReaderAPIWindowController: NSWindowController { return } - guard !AccountManager.shared.duplicateServiceAccount(type: accountType, username: usernameTextField.stringValue) else { + guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: accountType, username: usernameTextField.stringValue) else { self.errorMessageLabel.stringValue = NSLocalizedString("There is already an account of this type with that username created.", comment: "Duplicate Error") return } diff --git a/iOS/Account/FeedWranglerAccountViewController.swift b/iOS/Account/FeedWranglerAccountViewController.swift index 06bf376ee..c5dd3944c 100644 --- a/iOS/Account/FeedWranglerAccountViewController.swift +++ b/iOS/Account/FeedWranglerAccountViewController.swift @@ -80,7 +80,7 @@ class FeedWranglerAccountViewController: UITableViewController { // When you fill in the email address via auto-complete it adds extra whitespace let trimmedEmail = email.trimmingCharacters(in: .whitespaces) - guard !AccountManager.shared.duplicateServiceAccount(type: .feedWrangler, username: trimmedEmail) else { + guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: .feedWrangler, username: trimmedEmail) else { showError(NSLocalizedString("There is already a FeedWrangler account with that username created.", comment: "Duplicate Error")) return } diff --git a/iOS/Account/NewsBlurAccountViewController.swift b/iOS/Account/NewsBlurAccountViewController.swift index c1bed5e2d..cf942c3f4 100644 --- a/iOS/Account/NewsBlurAccountViewController.swift +++ b/iOS/Account/NewsBlurAccountViewController.swift @@ -80,13 +80,19 @@ class NewsBlurAccountViewController: UITableViewController { return } + // When you fill in the email address via auto-complete it adds extra whitespace + let trimmedUsername = username.trimmingCharacters(in: .whitespaces) + + guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: .newsBlur, username: trimmedUsername) else { + showError(NSLocalizedString("There is already a NewsBlur account with that username created.", comment: "Duplicate Error")) + return + } + let password = passwordTextField.text ?? "" startAnimatingActivityIndicator() disableNavigation() - // When you fill in the email address via auto-complete it adds extra whitespace - let trimmedUsername = username.trimmingCharacters(in: .whitespaces) let credentials = Credentials(type: .newsBlurBasic, username: trimmedUsername, secret: password) Account.validateCredentials(type: .newsBlur, credentials: credentials) { result in diff --git a/iOS/Account/ReaderAPIAccountViewController.swift b/iOS/Account/ReaderAPIAccountViewController.swift index 676dcb1ad..3eca028cd 100644 --- a/iOS/Account/ReaderAPIAccountViewController.swift +++ b/iOS/Account/ReaderAPIAccountViewController.swift @@ -109,7 +109,7 @@ class ReaderAPIAccountViewController: UITableViewController { } @IBAction func action(_ sender: Any) { - guard validateDataEntry() else { + guard validateDataEntry(), let type = accountType else { return } @@ -117,15 +117,18 @@ class ReaderAPIAccountViewController: UITableViewController { let password = passwordTextField.text! let url = apiURL()! + // When you fill in the email address via auto-complete it adds extra whitespace + let trimmedUsername = username.trimmingCharacters(in: .whitespaces) + + guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: type, username: trimmedUsername) else { + showError(NSLocalizedString("There is already an account of that type with that username created.", comment: "Duplicate Error")) + return + } + startAnimatingActivityIndicator() disableNavigation() - // When you fill in the email address via auto-complete it adds extra whitespace - let trimmedUsername = username.trimmingCharacters(in: .whitespaces) let credentials = Credentials(type: .readerBasic, username: trimmedUsername, secret: password) - guard let type = accountType else { - return - } Account.validateCredentials(type: type, credentials: credentials, endpoint: url) { result in self.stopAnimatingActivityIndicator()