Created
December 3, 2019 11:08
-
-
Save albertodebortoli/237fdd86dfd2e0711ec78eb02874aa43 to your computer and use it in GitHub Desktop.
used by 'Lessons learned from handling JWT on mobile' article on Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthorizationValueProvider { | |
private let authenticationInfoStore: AuthenticationInfoStorage | |
private let tokenRefreshAPI: TokenRefreshing | |
private let queue = DispatchQueue(label: <#label#>, qos: .userInteractive) | |
private let semaphore = DispatchSemaphore(value: 1) | |
init(tokenRefreshAPI: TokenRefreshing, | |
authenticationInfoStore: AuthenticationInfoStorage) { | |
self.tokenRefreshAPI = tokenRefreshAPI | |
self.authenticationInfoStore = authenticationInfoStore | |
} | |
func getValidUserAuthorization(completion: @escaping (Result<AuthorizationValue, Error>) -> Void) { | |
queue.async { | |
self.getValidUserAuthorizationInMutualExclusion(completion: completion) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment