我在使用SSO(单点登录)登录时遇到Alamofire的问题
Alamofire 4.7.2 Swift 4.1
使用正确的凭据登录后,我退出了,之后我也可以使用错误的凭据登录。如果我杀了应用程序,它可以正常工作。
我试过
Alamofire.SessionManager.default.session.getAllTasks { (tasks) in
tasks.forEach({ $0.cancel() })
}
URLSession.shared.flush {
URLSession.shared.reset {
}
}
URLSession.shared.invalidateAndCancel()
Alamofire.SessionManager.default.session.flush {
Alamofire.SessionManager.default.session.reset {
var storage: URLCredentialStorage? {
return Alamofire.SessionManager.default.session.configuration.urlCredentialStorage
}
print("Credentials found: \(storage?.allCredentials.first?.value.first?.value.user ?? "nil")\n")
if let protectionSpace: URLProtectionSpace = storage?.allCredentials.first?.key, let credential = storage?.allCredentials.first?.value.first?.value {
storage?.remove(credential, for: protectionSpace)
NSLog("Credentials removed: %@", credential.user ?? "nil")
print("Credentials removed: \(credential.user ?? "")\n")
print("Credentials found: \(storage?.allCredentials.first?.value.first?.value.user ?? "nil")\n")
}
DispatchQueue.main.sync {
listener(response, error)
}
}
}