From 59d427d62644ff8b51ea8d3dd76eecf83b15447b Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 24 Sep 2020 18:02:12 -0500 Subject: [PATCH] Don't allow duplicate Feedly or FeedWrangler accounts. Issue #2448 --- .../FeedWranglerAccountViewController.swift | 11 ++++++++--- iOS/Account/FeedbinAccountViewController.swift | 14 ++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/iOS/Account/FeedWranglerAccountViewController.swift b/iOS/Account/FeedWranglerAccountViewController.swift index 39d1e2bbd..92e12db32 100644 --- a/iOS/Account/FeedWranglerAccountViewController.swift +++ b/iOS/Account/FeedWranglerAccountViewController.swift @@ -72,17 +72,22 @@ class FeedWranglerAccountViewController: UITableViewController { } @IBAction func action(_ sender: Any) { - guard let email = emailTextField.text, let password = passwordTextField.text else { showError(NSLocalizedString("Username & password required.", comment: "Credentials Error")) return } + // 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 { + showError(NSLocalizedString("There is already a FeedWrangler account with that username created.", comment: "Duplicate Error")) + return + } + resignFirstResponder() toggleActivityIndicatorAnimation(visible: true) setNavigationEnabled(to: false) - // When you fill in the email address via auto-complete it adds extra whitespace - let trimmedEmail = email.trimmingCharacters(in: .whitespaces) let credentials = Credentials(type: .feedWranglerBasic, username: trimmedEmail, secret: password) Account.validateCredentials(type: .feedWrangler, credentials: credentials) { result in diff --git a/iOS/Account/FeedbinAccountViewController.swift b/iOS/Account/FeedbinAccountViewController.swift index b33638b5d..c9c60d5e0 100644 --- a/iOS/Account/FeedbinAccountViewController.swift +++ b/iOS/Account/FeedbinAccountViewController.swift @@ -73,17 +73,23 @@ class FeedbinAccountViewController: UITableViewController { } @IBAction func action(_ sender: Any) { - guard let email = emailTextField.text, let password = passwordTextField.text else { showError(NSLocalizedString("Username & password required.", comment: "Credentials Error")) return } - resignFirstResponder() - toggleActivityIndicatorAnimation(visible: true) - setNavigationEnabled(to: false) // 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: .feedbin, username: trimmedEmail) else { + showError(NSLocalizedString("There is already a Feedbin account with that username created.", comment: "Duplicate Error")) + return + } + + resignFirstResponder() + toggleActivityIndicatorAnimation(visible: true) + setNavigationEnabled(to: false) + let credentials = Credentials(type: .basic, username: trimmedEmail, secret: password) Account.validateCredentials(type: .feedbin, credentials: credentials) { result in self.toggleActivityIndicatorAnimation(visible: false)