Skip to content

Commit 67009a9

Browse files
authored
fix(Storage): Use async getidentityid (#1544)
1 parent 2a5472f commit 67009a9

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

AmplifyPlugins/Core/AWSPluginsTestCommon/MockAWSAuthService.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ public class MockAWSAuthService: AWSAuthServiceBehavior {
3636

3737
return .success(identityId ?? "IdentityId")
3838
}
39+
40+
public func getIdentityID(completion: @escaping (Result<String, AuthError>) -> Void) {
41+
if let error = getIdentityIdError {
42+
completion(.failure(error))
43+
}
44+
45+
completion(.success(identityId ?? "IdentityId"))
46+
}
3947

4048
public func getToken() -> Result<String, AuthError> {
4149
if let error = getTokenError {

AmplifyPlugins/Storage/AWSS3StoragePlugin/Configuration/AWSS3PluginPrefixResolver.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ struct StorageAccessLevelAwarePrefixResolver: AWSS3PluginPrefixResolver {
6262
func resolvePrefix(for accessLevel: StorageAccessLevel,
6363
targetIdentityId: String?,
6464
completion: @escaping (Result<String, StorageError>) -> Void) {
65-
let identityIdResult = authService.getIdentityId()
66-
switch identityIdResult {
67-
case .success(let identityId):
68-
let prefix = StorageRequestUtils.getAccessLevelPrefix(accessLevel: accessLevel,
69-
identityId: identityId,
70-
targetIdentityId: targetIdentityId)
71-
completion(.success(prefix))
72-
case .failure(let error):
73-
completion(.failure(StorageError.authError(error.errorDescription, error.recoverySuggestion)))
65+
authService.getIdentityID { identityIdResult in
66+
switch identityIdResult {
67+
case .success(let identityId):
68+
let prefix = StorageRequestUtils.getAccessLevelPrefix(accessLevel: accessLevel,
69+
identityId: identityId,
70+
targetIdentityId: targetIdentityId)
71+
completion(.success(prefix))
72+
case .failure(let error):
73+
completion(.failure(StorageError.authError(error.errorDescription, error.recoverySuggestion)))
74+
}
7475
}
7576
}
7677
}

AmplifyPlugins/Storage/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ SPEC CHECKSUMS:
112112

113113
PODFILE CHECKSUM: 23c3028505a2f56c001d01c66c1622dff6f8dd8e
114114

115-
COCOAPODS: 1.10.1
115+
COCOAPODS: 1.11.2

0 commit comments

Comments
 (0)