mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Change Credentials to be a struct instead of an enum
This commit is contained in:
@@ -62,7 +62,7 @@ struct SettingsFeedbinAccountView : View {
|
||||
error = ""
|
||||
|
||||
let emailAddress = viewModel.email.trimmingCharacters(in: .whitespaces)
|
||||
let credentials = Credentials.basic(username: emailAddress, password: viewModel.password)
|
||||
let credentials = Credentials(type: .basic, username: emailAddress, secret: viewModel.password)
|
||||
|
||||
Account.validateCredentials(type: .feedbin, credentials: credentials) { result in
|
||||
|
||||
@@ -85,7 +85,7 @@ struct SettingsFeedbinAccountView : View {
|
||||
do {
|
||||
|
||||
do {
|
||||
try workAccount.removeCredentials()
|
||||
try workAccount.removeCredentials(type: .basic)
|
||||
} catch {}
|
||||
try workAccount.storeCredentials(credentials)
|
||||
|
||||
@@ -125,9 +125,8 @@ struct SettingsFeedbinAccountView : View {
|
||||
|
||||
init(account: Account) {
|
||||
self.account = account
|
||||
if case .basic(let username, let password) = try? account.retrieveCredentials() {
|
||||
self.email = username
|
||||
self.password = password
|
||||
if let credentials = try? account.retrieveCredentials(type: .basic) {
|
||||
self.email = credentials.username
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ struct SettingsReaderAPIAccountView : View {
|
||||
error = ""
|
||||
|
||||
let emailAddress = viewModel.email.trimmingCharacters(in: .whitespaces)
|
||||
let credentials = Credentials.readerAPIBasicLogin(username: emailAddress, password: viewModel.password)
|
||||
let credentials = Credentials(type: .readerBasic, username: emailAddress, secret: viewModel.password)
|
||||
guard let apiURL = URL(string: viewModel.apiURL) else {
|
||||
self.error = "Invalid API URL."
|
||||
return
|
||||
@@ -94,11 +94,13 @@ struct SettingsReaderAPIAccountView : View {
|
||||
do {
|
||||
|
||||
do {
|
||||
try workAccount.removeCredentials()
|
||||
try workAccount.removeCredentials(type: .readerBasic)
|
||||
try workAccount.removeCredentials(type: .readerAPIKey)
|
||||
} catch {}
|
||||
|
||||
workAccount.endpointURL = apiURL
|
||||
|
||||
try workAccount.storeCredentials(credentials)
|
||||
try workAccount.storeCredentials(validatedCredentials)
|
||||
|
||||
if newAccount {
|
||||
@@ -136,9 +138,8 @@ struct SettingsReaderAPIAccountView : View {
|
||||
init(account: Account) {
|
||||
self.account = account
|
||||
self.accountType = account.type
|
||||
if case .readerAPIBasicLogin(let username, let password) = try? account.retrieveCredentials() {
|
||||
self.email = username
|
||||
self.password = password
|
||||
if let credentials = try? account.retrieveCredentials(type: .readerBasic) {
|
||||
self.email = credentials.username
|
||||
self.apiURL = account.endpointURL?.absoluteString ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user