diff --git a/Frameworks/Account/FeedWrangler/FeedWranglerAPICaller.swift b/Frameworks/Account/FeedWrangler/FeedWranglerAPICaller.swift index d2feee7b5..65c2e41cb 100644 --- a/Frameworks/Account/FeedWrangler/FeedWranglerAPICaller.swift +++ b/Frameworks/Account/FeedWrangler/FeedWranglerAPICaller.swift @@ -32,6 +32,21 @@ final class FeedWranglerAPICaller: NSObject { transport.cancelAll() } + func logout(completion: @escaping (Result) -> Void) { + let url = FeedWranglerConfig.clientURL.appendingPathComponent("users/logout") + let request = URLRequest(url: url, credentials: credentials) + + transport.send(request: request) { result in + switch result { + case .success: + completion(.success(())) + + case .failure(let error): + completion(.failure(error)) + } + } + } + func validateCredentials(completion: @escaping (Result) -> Void) { let url = FeedWranglerConfig.clientURL.appendingPathComponent("users/authorize") let username = self.credentials?.username ?? "" diff --git a/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift b/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift index dd3f69175..f1b4352f4 100644 --- a/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift +++ b/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift @@ -57,7 +57,7 @@ final class FeedWranglerAccountDelegate: AccountDelegate { } func accountWillBeDeleted(_ account: Account) { - // noop + caller.logout() { _ in } } func refreshAll(for account: Account, completion: @escaping (Result) -> Void) {