logout when deleting account
This commit is contained in:
parent
b3c053964c
commit
0f105c8421
|
@ -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 ?? ""
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue