Store correct credentials for FreshRSS

This commit is contained in:
Maurice Parker 2019-09-14 15:41:35 -05:00
parent 157bd57c5e
commit 16954393c0
1 changed files with 33 additions and 34 deletions

View File

@ -75,41 +75,40 @@ struct SettingsReaderAPIAccountView : View {
self.busy = false
switch result {
case .success(let authenticated):
case .success(let validatedCredentials):
if (authenticated != nil) {
guard let validatedCredentials = validatedCredentials else {
self.error = "Invalid email/password combination."
return
}
var newAccount = false
let workAccount: Account
if self.viewModel.account == nil {
workAccount = AccountManager.shared.createAccount(type: self.viewModel.accountType)
newAccount = true
} else {
workAccount = self.viewModel.account!
}
var newAccount = false
let workAccount: Account
if self.viewModel.account == nil {
workAccount = AccountManager.shared.createAccount(type: self.viewModel.accountType)
newAccount = true
} else {
workAccount = self.viewModel.account!
}
do {
do {
try workAccount.removeCredentials()
} catch {}
do {
try workAccount.removeCredentials()
} catch {}
workAccount.endpointURL = apiURL
workAccount.endpointURL = apiURL
try workAccount.storeCredentials(validatedCredentials)
try workAccount.storeCredentials(credentials)
if newAccount {
workAccount.refreshAll() { result in }
}
self.dismiss()
} catch {
self.error = "Keychain error while storing credentials."
if newAccount {
workAccount.refreshAll() { result in }
}
} else {
self.error = "Invalid email/password combination."
self.dismiss()
} catch {
self.error = "Keychain error while storing credentials."
}
case .failure: