Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GT-2060 Removed getPersistedResponse() and added isAuthenticated computed property on UserAuthentication to check if user is authenticated #2332

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Removed getPersistedResponse() and added isAuthenticated computed pro…
…perty on UserAuthentication to check if user is authenticated
levieggertcru committed Nov 7, 2024
commit 141e68fae9a3e5f5bf74bd50b76a4f6472de9004
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import Combine

protocol AuthenticationProviderInterface {

func getPersistedResponse() -> AuthenticationProviderResponse?
func authenticatePublisher(presentingViewController: UIViewController) -> AnyPublisher<AuthenticationProviderResponse, Error>
func renewTokenPublisher() -> AnyPublisher<AuthenticationProviderResponse, Error>
func signOutPublisher() -> AnyPublisher<Void, Error>
Original file line number Diff line number Diff line change
@@ -45,13 +45,6 @@ extension AppleAuthentication: AuthenticationProviderInterface {
return .success(response)
}

func getPersistedResponse() -> AuthenticationProviderResponse? {

// TODO: - access token renewal will come through MobileContentAPI?

return nil
}

func authenticatePublisher(presentingViewController: UIViewController) -> AnyPublisher<AuthenticationProviderResponse, Error> {

return authenticatePublisher()
Original file line number Diff line number Diff line change
@@ -40,18 +40,6 @@ extension FacebookAuthentication: AuthenticationProviderInterface {
return .success(response)
}

func getPersistedResponse() -> AuthenticationProviderResponse? {

switch getResponseForPersistedData() {

case .success(let response):
return response

case .failure( _):
return nil
}
}

func authenticatePublisher(presentingViewController: UIViewController) -> AnyPublisher<AuthenticationProviderResponse, Error> {

return authenticatePublisher(from: presentingViewController)
Original file line number Diff line number Diff line change
@@ -40,18 +40,6 @@ extension GoogleAuthentication: AuthenticationProviderInterface {
return .success(response)
}

func getPersistedResponse() -> AuthenticationProviderResponse? {

switch getResponseForPersistedData() {

case .success(let response):
return response

case .failure( _):
return nil
}
}

func authenticatePublisher(presentingViewController: UIViewController) -> AnyPublisher<AuthenticationProviderResponse, Error> {

return authenticatePublisher(from: presentingViewController)
Original file line number Diff line number Diff line change
@@ -23,6 +23,15 @@ class UserAuthentication {
self.mobileContentAuthTokenRepository = mobileContentAuthTokenRepository
}

var isAuthenticated: Bool {

guard let authTokenData = mobileContentAuthTokenRepository.getCachedAuthTokenModel() else {
return false
}

return !authTokenData.isExpired
}

func getIsAuthenticatedChangedPublisher() -> AnyPublisher<Bool, Never> {

return mobileContentAuthTokenRepository.getAuthTokenChangedPublisher()
@@ -62,10 +71,6 @@ class UserAuthentication {
return lastAuthenticatedProviderCache.getLastAuthenticatedProvider()
}

func getPersistedResponse() -> AuthenticationProviderResponse? {
return getLastAuthenticatedProvider()?.getPersistedResponse()
}

func renewTokenPublisher() -> AnyPublisher<MobileContentAuthTokenDataModel, MobileContentApiError> {

guard let lastAuthenticatedProvider = getLastAuthenticatedProviderType() else {