Skip to content

Commit 5229f29

Browse files
[PP-694] Use token auth for annotations (#370)
* Update project.pbxproj * Use token for annotations calls * In progress token improvements * Update project.pbxproj * Update TPPAnnotations.swift * Update NYPLNetworkExecutorMock.swift * Clean up * Resolve login failure when attempting to update tokens * Update project.pbxproj * Update project.pbxproj * Update project.pbxproj * Update NYPLNetworkExecutorMock.swift
1 parent 20aa4d1 commit 5229f29

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

Palace.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -4782,7 +4782,7 @@
47824782
CODE_SIGN_IDENTITY = "Apple Distribution";
47834783
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution";
47844784
CODE_SIGN_STYLE = Manual;
4785-
CURRENT_PROJECT_VERSION = 224;
4785+
CURRENT_PROJECT_VERSION = 225;
47864786
DEVELOPMENT_TEAM = 88CBA74T8K;
47874787
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
47884788
ENABLE_BITCODE = NO;
@@ -4840,7 +4840,7 @@
48404840
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
48414841
CODE_SIGN_ENTITLEMENTS = Palace/SimplyE.entitlements;
48424842
CODE_SIGN_IDENTITY = "iPhone Distribution";
4843-
CURRENT_PROJECT_VERSION = 224;
4843+
CURRENT_PROJECT_VERSION = 225;
48444844
DEVELOPMENT_TEAM = 88CBA74T8K;
48454845
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
48464846
ENABLE_BITCODE = NO;
@@ -5024,7 +5024,7 @@
50245024
CODE_SIGN_IDENTITY = "Apple Development";
50255025
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution";
50265026
CODE_SIGN_STYLE = Manual;
5027-
CURRENT_PROJECT_VERSION = 224;
5027+
CURRENT_PROJECT_VERSION = 225;
50285028
DEVELOPMENT_TEAM = "";
50295029
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
50305030
ENABLE_BITCODE = NO;
@@ -5084,7 +5084,7 @@
50845084
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
50855085
CODE_SIGN_ENTITLEMENTS = Palace/SimplyE.entitlements;
50865086
CODE_SIGN_IDENTITY = "iPhone Distribution";
5087-
CURRENT_PROJECT_VERSION = 224;
5087+
CURRENT_PROJECT_VERSION = 225;
50885088
DEVELOPMENT_TEAM = 88CBA74T8K;
50895089
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
50905090
ENABLE_BITCODE = NO;

Palace/Accounts/User/TPPUserAccount.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private enum StorageKey: String {
263263
let isTokenExpired = hasAuthToken() && authTokenHasExpired
264264
let isTokenAuthAndMissing = (authDefinition?.isToken ?? false) && !hasAuthToken()
265265

266-
return isTokenExpired || isTokenAuthAndMissing
266+
return isSignedIn() && (isTokenExpired || isTokenAuthAndMissing)
267267
}
268268

269269
func hasAdobeToken() -> Bool {

Palace/Network/TPPNetworkExecutor.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extension TPPNetworkExecutor: TPPRequestExecuting {
7878
/// the network or from the cache.
7979
/// - Returns: The task issueing the given request.
8080
@discardableResult
81-
func executeRequest(_ req: URLRequest, completion: @escaping (_: NYPLResult<Data>) -> Void) -> URLSessionDataTask {
81+
func executeRequest(_ req: URLRequest, completion: @escaping (_: NYPLResult<Data>) -> Void) -> URLSessionDataTask? {
8282
let userAccount = TPPUserAccount.sharedAccount()
8383

8484
if let authDefinition = userAccount.authDefinition, authDefinition.isSaml {
@@ -87,13 +87,13 @@ extension TPPNetworkExecutor: TPPRequestExecuting {
8787

8888
if userAccount.isTokenRefreshRequired() {
8989
handleTokenRefresh(for: req, completion: completion)
90-
return URLSessionDataTask()
90+
return nil
9191
}
9292

9393
if req.hasRetried {
9494
let error = createErrorForRetryFailure()
9595
completion(NYPLResult.failure(error, nil))
96-
return URLSessionDataTask()
96+
return nil
9797
}
9898

9999
return performDataTask(with: req, completion: completion)

Palace/Network/TPPRequestExecuting.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protocol TPPRequestExecuting {
1919
/// - Returns: The task issueing the given request.
2020
@discardableResult
2121
func executeRequest(_ req: URLRequest,
22-
completion: @escaping (_: NYPLResult<Data>) -> Void) -> URLSessionDataTask
22+
completion: @escaping (_: NYPLResult<Data>) -> Void) -> URLSessionDataTask?
2323

2424
var requestTimeout: TimeInterval {get}
2525

PalaceTests/Mocks/NYPLNetworkExecutorMock.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TPPRequestExecutorMock: TPPRequestExecuting {
2222
}
2323

2424
func executeRequest(_ req: URLRequest,
25-
completion: @escaping (NYPLResult<Data>) -> Void) -> URLSessionDataTask {
25+
completion: @escaping (NYPLResult<Data>) -> Void) -> URLSessionDataTask? {
2626

2727
DispatchQueue.main.async {
2828
guard let url = req.url else {

0 commit comments

Comments
 (0)