Check for duplicate accounts and make sure it doesn't interfere with credentials updates
This commit is contained in:
parent
3a1570f6c6
commit
515dd5f63f
@ -56,7 +56,7 @@ class AccountsFeedWranglerWindowController: NSWindowController {
|
|||||||
return
|
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")
|
self.errorMessageLabel.stringValue = NSLocalizedString("There is already a FeedWrangler account with that username created.", comment: "Duplicate Error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class AccountsNewsBlurWindowController: NSWindowController {
|
|||||||
return
|
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")
|
self.errorMessageLabel.stringValue = NSLocalizedString("There is already a NewsBlur account with that username created.", comment: "Duplicate Error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class AccountsReaderAPIWindowController: NSWindowController {
|
|||||||
return
|
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")
|
self.errorMessageLabel.stringValue = NSLocalizedString("There is already an account of this type with that username created.", comment: "Duplicate Error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ class FeedWranglerAccountViewController: UITableViewController {
|
|||||||
// When you fill in the email address via auto-complete it adds extra whitespace
|
// When you fill in the email address via auto-complete it adds extra whitespace
|
||||||
let trimmedEmail = email.trimmingCharacters(in: .whitespaces)
|
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"))
|
showError(NSLocalizedString("There is already a FeedWrangler account with that username created.", comment: "Duplicate Error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -80,13 +80,19 @@ class NewsBlurAccountViewController: UITableViewController {
|
|||||||
return
|
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 ?? ""
|
let password = passwordTextField.text ?? ""
|
||||||
|
|
||||||
startAnimatingActivityIndicator()
|
startAnimatingActivityIndicator()
|
||||||
disableNavigation()
|
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)
|
let credentials = Credentials(type: .newsBlurBasic, username: trimmedUsername, secret: password)
|
||||||
Account.validateCredentials(type: .newsBlur, credentials: credentials) { result in
|
Account.validateCredentials(type: .newsBlur, credentials: credentials) { result in
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class ReaderAPIAccountViewController: UITableViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func action(_ sender: Any) {
|
@IBAction func action(_ sender: Any) {
|
||||||
guard validateDataEntry() else {
|
guard validateDataEntry(), let type = accountType else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,15 +117,18 @@ class ReaderAPIAccountViewController: UITableViewController {
|
|||||||
let password = passwordTextField.text!
|
let password = passwordTextField.text!
|
||||||
let url = apiURL()!
|
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()
|
startAnimatingActivityIndicator()
|
||||||
disableNavigation()
|
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)
|
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
|
Account.validateCredentials(type: type, credentials: credentials, endpoint: url) { result in
|
||||||
|
|
||||||
self.stopAnimatingActivityIndicator()
|
self.stopAnimatingActivityIndicator()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user