Store correct credentials for FreshRSS
This commit is contained in:
parent
157bd57c5e
commit
16954393c0
|
@ -75,41 +75,40 @@ struct SettingsReaderAPIAccountView : View {
|
||||||
self.busy = false
|
self.busy = false
|
||||||
|
|
||||||
switch result {
|
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
|
var newAccount = false
|
||||||
let workAccount: Account
|
let workAccount: Account
|
||||||
if self.viewModel.account == nil {
|
if self.viewModel.account == nil {
|
||||||
workAccount = AccountManager.shared.createAccount(type: self.viewModel.accountType)
|
workAccount = AccountManager.shared.createAccount(type: self.viewModel.accountType)
|
||||||
newAccount = true
|
newAccount = true
|
||||||
} else {
|
} else {
|
||||||
workAccount = self.viewModel.account!
|
workAccount = self.viewModel.account!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
try workAccount.removeCredentials()
|
||||||
|
} catch {}
|
||||||
|
|
||||||
do {
|
workAccount.endpointURL = apiURL
|
||||||
try workAccount.removeCredentials()
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
workAccount.endpointURL = apiURL
|
try workAccount.storeCredentials(validatedCredentials)
|
||||||
|
|
||||||
try workAccount.storeCredentials(credentials)
|
if newAccount {
|
||||||
|
workAccount.refreshAll() { result in }
|
||||||
if newAccount {
|
|
||||||
workAccount.refreshAll() { result in }
|
|
||||||
}
|
|
||||||
|
|
||||||
self.dismiss()
|
|
||||||
|
|
||||||
} catch {
|
|
||||||
self.error = "Keychain error while storing credentials."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
self.dismiss()
|
||||||
self.error = "Invalid email/password combination."
|
|
||||||
|
} catch {
|
||||||
|
self.error = "Keychain error while storing credentials."
|
||||||
}
|
}
|
||||||
|
|
||||||
case .failure:
|
case .failure:
|
||||||
|
|
Loading…
Reference in New Issue