Skip to content

Commit 122dceb

Browse files
authored
fix(auth): User pool token, user sub should be returned for signedIn user with no identityPool config (#632)
1 parent ec6da34 commit 122dceb

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

AmplifyPlugins/Auth/AWSCognitoAuthPlugin/Dependency/AuthorizationProviderAdapter+SignedInSession.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ extension AuthorizationProviderAdapter {
112112
if let urlError = error as NSError?, urlError.domain == NSURLErrorDomain {
113113
self.fetchSignedInSessionWithOfflineError(completionHandler)
114114

115-
} else if let cognitoIdentityPoolError = error as NSError?,
116-
cognitoIdentityPoolError.domain == AWSCognitoIdentityErrorDomain,
117-
cognitoIdentityPoolError.code == AWSCognitoIdentityErrorType.notAuthorized.rawValue {
115+
} else if self.isErrorCausedByMisconfiguredIdentityPool(error!) {
118116
self.fetchSignedInSessionWithNoIdentityPool(withTokensResult: tokenResult,
119117
userSubResult: userSubResult,
120118
completionHandler)
@@ -222,4 +220,17 @@ extension AuthorizationProviderAdapter {
222220
cognitoTokensResult: tokenResult)
223221
completionHandler(.success(authSession))
224222
}
223+
224+
private func isErrorCausedByMisconfiguredIdentityPool(_ error: Error) -> Bool {
225+
if let awsMobileClientError = error as? AWSMobileClientError,
226+
case .cognitoIdentityPoolNotConfigured = awsMobileClientError {
227+
return true
228+
}
229+
if let cognitoIdentityPoolError = error as NSError?,
230+
cognitoIdentityPoolError.domain == AWSCognitoIdentityErrorDomain,
231+
cognitoIdentityPoolError.code == AWSCognitoIdentityErrorType.notAuthorized.rawValue {
232+
return true
233+
}
234+
return false
235+
}
225236
}

AmplifyPlugins/Auth/Podfile.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ PODS:
99
- Amplify (= 1.0.4)
1010
- AWSCore (~> 2.14.0)
1111
- AWSPluginsCore (= 1.0.4)
12-
- AWSAuthCore (2.14.0):
13-
- AWSCore (= 2.14.0)
14-
- AWSCognitoIdentityProvider (2.14.0):
12+
- AWSAuthCore (2.14.2):
13+
- AWSCore (= 2.14.2)
14+
- AWSCognitoIdentityProvider (2.14.2):
1515
- AWSCognitoIdentityProviderASF (= 1.0.1)
16-
- AWSCore (= 2.14.0)
16+
- AWSCore (= 2.14.2)
1717
- AWSCognitoIdentityProviderASF (1.0.1)
18-
- AWSCore (2.14.0)
19-
- AWSMobileClient (2.14.0):
20-
- AWSAuthCore (= 2.14.0)
21-
- AWSCognitoIdentityProvider (= 2.14.0)
18+
- AWSCore (2.14.2)
19+
- AWSMobileClient (2.14.2):
20+
- AWSAuthCore (= 2.14.2)
21+
- AWSCognitoIdentityProvider (= 2.14.2)
2222
- AWSPluginsCore (1.0.4):
2323
- Amplify (= 1.0.4)
2424
- AWSCore (~> 2.14.0)
2525
- AWSMobileClient (~> 2.14.0)
2626
- CwlCatchException (1.0.2)
2727
- CwlPreconditionTesting (1.1.1):
2828
- CwlCatchException
29-
- SwiftFormat/CLI (0.44.14)
29+
- SwiftFormat/CLI (0.44.16)
3030
- SwiftLint (0.39.2)
3131

3232
DEPENDENCIES:
@@ -74,15 +74,15 @@ CHECKOUT OPTIONS:
7474
SPEC CHECKSUMS:
7575
Amplify: 7626e435f3e78ac3508252557e375f994d5d5154
7676
AmplifyTestCommon: fb6f2e2e876cd4ec582c55e9bf7cb0bfe2ae21e9
77-
AWSAuthCore: 6b337af04751dcbb4bc50f18dbed0343ba345e17
78-
AWSCognitoIdentityProvider: bd4cf5f70b9224b1ea42b423a75716cafb8f7ac4
77+
AWSAuthCore: 7ab6f5ab60ba8bb91a4868581946a993cbbae76d
78+
AWSCognitoIdentityProvider: 609856c741ef86037055223b3a46f4eeb49319d0
7979
AWSCognitoIdentityProviderASF: f94f1a502e72ef3d0a1de93e10bf7a79c8698118
80-
AWSCore: 6398ca88010f34653a07d54a252affe920a99965
81-
AWSMobileClient: 0f4ae3f60722fc2cec7ca926fd442ff55a2154a5
80+
AWSCore: 80da498ab0979e77dbdc7690a61ceaaccfb0499a
81+
AWSMobileClient: b80f21439aa95df2375e7acdde76d2f60c12f4b7
8282
AWSPluginsCore: 646f8c2d831a52f2293da0dfd59a31eee61f6ad5
8383
CwlCatchException: 70a52ae44ea5d46db7bd385f801a94942420cd8c
8484
CwlPreconditionTesting: d33a4e4f285c0b885fddcae5dfedfbb34d4f3961
85-
SwiftFormat: a5ab293a7f6a812bec6f4ffc5507b7ed08f7f6e1
85+
SwiftFormat: c44bd17c23f237956f67205a422a1bd352d42e4c
8686
SwiftLint: 22ccbbe3b8008684be5955693bab135e0ed6a447
8787

8888
PODFILE CHECKSUM: 371cf67fe35ebb5167d0880bad12b01618a0fb0e

0 commit comments

Comments
 (0)