logout when deleting account

This commit is contained in:
Jonathan Bennett 2019-11-21 01:17:34 -05:00
parent b3c053964c
commit 0f105c8421
2 changed files with 16 additions and 1 deletions

View File

@ -32,6 +32,21 @@ final class FeedWranglerAPICaller: NSObject {
transport.cancelAll() transport.cancelAll()
} }
func logout(completion: @escaping (Result<Void, Error>) -> 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<Credentials?, Error>) -> Void) { func validateCredentials(completion: @escaping (Result<Credentials?, Error>) -> Void) {
let url = FeedWranglerConfig.clientURL.appendingPathComponent("users/authorize") let url = FeedWranglerConfig.clientURL.appendingPathComponent("users/authorize")
let username = self.credentials?.username ?? "" let username = self.credentials?.username ?? ""

View File

@ -57,7 +57,7 @@ final class FeedWranglerAccountDelegate: AccountDelegate {
} }
func accountWillBeDeleted(_ account: Account) { func accountWillBeDeleted(_ account: Account) {
// noop caller.logout() { _ in }
} }
func refreshAll(for account: Account, completion: @escaping (Result<Void, Error>) -> Void) { func refreshAll(for account: Account, completion: @escaping (Result<Void, Error>) -> Void) {