Skip to content

Commit 8d77a24

Browse files
authored
Revert "Merge branch 'release-candidate' into main" (#871)
This reverts commit a88a109, reversing changes made to 324ebad.
1 parent a88a109 commit 8d77a24

File tree

11 files changed

+39
-77
lines changed

11 files changed

+39
-77
lines changed

packages/amplify_analytics_pinpoint/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ dependencies {
6767
api amplifyCore
6868

6969
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
70-
implementation 'com.amplifyframework:aws-analytics-pinpoint:1.25.1'
71-
implementation 'com.amplifyframework:aws-auth-cognito:1.25.1'
70+
implementation 'com.amplifyframework:aws-analytics-pinpoint:1.24.1'
71+
implementation 'com.amplifyframework:aws-auth-cognito:1.24.1'
7272
testImplementation 'junit:junit:4.13.2'
7373
testImplementation 'org.mockito:mockito-core:3.10.0'
7474
testImplementation 'org.mockito:mockito-inline:3.10.0'

packages/amplify_api/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ dependencies {
6565
api amplifyCore
6666

6767
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
68-
implementation "com.amplifyframework:aws-api:1.25.1"
69-
implementation "com.amplifyframework:aws-api-appsync:1.25.1"
68+
implementation "com.amplifyframework:aws-api:1.24.1"
69+
implementation "com.amplifyframework:aws-api-appsync:1.24.1"
7070
implementation 'androidx.test.ext:junit-ktx:1.1.3'
7171

7272
testImplementation 'junit:junit:4.13.2'

packages/amplify_auth_cognito/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ android {
6262
dependencies {
6363
api amplifyCore
6464
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
65-
implementation 'com.amplifyframework:aws-auth-cognito:1.25.1'
65+
implementation 'com.amplifyframework:aws-auth-cognito:1.24.1'
6666
testImplementation 'junit:junit:4.13.2'
6767
testImplementation 'org.mockito:mockito-core:3.10.0'
6868
testImplementation 'org.mockito:mockito-inline:3.10.0'

packages/amplify_auth_cognito/android/src/main/kotlin/com/amazonaws/amplify/amplify_auth_cognito/AuthCognito.kt

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import com.amazonaws.amplify.amplify_auth_cognito.types.FlutterResendUserAttribu
5151
import com.amazonaws.amplify.amplify_auth_cognito.types.FlutterResendUserAttributeConfirmationCodeResult
5252
import com.amazonaws.amplify.amplify_core.exception.ExceptionUtil.Companion.handleAddPluginException
5353
import com.amazonaws.amplify.amplify_auth_cognito.utils.isRedirectActivityDeclared
54-
import com.amazonaws.mobile.client.AWSMobileClient
5554
import com.amplifyframework.auth.AuthException
5655
import com.amplifyframework.auth.AuthProvider
5756
import com.amplifyframework.auth.AuthSession
@@ -387,37 +386,13 @@ public class AuthCognito : FlutterPlugin, ActivityAware, MethodCallHandler, Plug
387386

388387
private fun onGetCurrentUser(@NonNull flutterResult: Result) {
389388
try {
390-
/*
391-
Because Android does not preserve the user after session expiration but iOS does so,
392-
we need to use the mobileclient to get the old username to enforce platform parity.
393-
*/
394-
Amplify.Auth.fetchAuthSession(
395-
{ result ->
396-
val cognitoAuthSession = result as AWSCognitoAuthSession
397-
when (cognitoAuthSession.userSub.type) {
398-
// If the user sub accessor successful the user is present and the session should be valid
399-
AuthSessionResult.Type.SUCCESS -> {
400-
val awsMobileClient = AWSMobileClient.getInstance()
401-
val username = awsMobileClient.username
402-
prepareUserResult(flutterResult, AuthUser(cognitoAuthSession.userSub.toString(), username));
403-
}
404-
// If the user sub accessor failed, check the signIn state
405-
AuthSessionResult.Type.FAILURE -> {
406-
// if signedIn flag still true, we know session is expired so get the old user
407-
if (result.isSignedIn) {
408-
val awsMobileClient = AWSMobileClient.getInstance()
409-
val username = awsMobileClient.username
410-
val userid = awsMobileClient.userSub
411-
prepareUserResult(flutterResult, AuthUser(userid, username));
412-
// if signIn flag is false, we assume user is signed out so throw exception
413-
} else {
414-
errorHandler.handleAuthError(flutterResult, AuthException.SignedOutException())
415-
}
416-
}
417-
}
418-
},
419-
{ error -> errorHandler.handleAuthError(flutterResult, error) }
420-
)
389+
var user: AuthUser? = Amplify.Auth.currentUser;
390+
if (user is AuthUser) {
391+
prepareUserResult(flutterResult, user);
392+
} else {
393+
// TODO: Mechanism to check guest access status
394+
throw AuthException.SignedOutException(AuthException.GuestAccess.GUEST_ACCESS_DISABLED)
395+
}
421396
} catch (e: AuthException) {
422397
errorHandler.handleAuthError(flutterResult, e)
423398
} catch (e: Exception) {
@@ -602,15 +577,7 @@ public class AuthCognito : FlutterPlugin, ActivityAware, MethodCallHandler, Plug
602577
}
603578

604579
fun prepareCognitoSessionFailure(@NonNull flutterResult: Result, @NonNull result: AWSCognitoAuthSession) {
605-
// If a User Pool token's error is a SignedOutException, we send SignedOutException as
606-
// method call response because this indicates that the problem is not expired tokens,
607-
// but total lack of authentication (i.e. the user is signed out)
608-
var sessionException: AuthException = if (result.userPoolTokens.error is AuthException.SignedOutException) {
609-
AuthException.SignedOutException()
610-
} else {
611-
AuthException.SessionExpiredException()
612-
}
613-
errorHandler.handleAuthError(flutterResult, sessionException)
580+
errorHandler.handleAuthError(flutterResult, AuthException.SessionExpiredException())
614581
}
615582

616583
fun prepareSessionResult(@NonNull flutterResult: Result, @NonNull result: AuthSession) {

packages/amplify_auth_cognito/android/src/test/kotlin/com/amazonaws/amplify/amplify_auth_cognito/AmplifyAuthCognitoPluginTest.kt

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,8 @@ class AmplifyAuthCognitoPluginTest {
8080
private val mockSignInResult = AuthSignInResult(false, signInStep)
8181
private val mockResetPasswordResult = AuthResetPasswordResult(false, resetStep)
8282
private val mockUpdateUserAttributeResult = AuthUpdateAttributeResult(true, updateAttributeStep)
83-
private val id = AuthSessionResult.success("id")
84-
private val awsCredentials: AuthSessionResult<AWSCredentials> = AuthSessionResult.success(BasicAWSCredentials("access", "secret"))
85-
private val userSub = AuthSessionResult.success("sub")
86-
private val tokens = AuthSessionResult.success(AWSCognitoUserPoolTokens("access", "id", "refresh"))
87-
private val mockSession = AWSCognitoAuthSession(
88-
true,
89-
id,
90-
awsCredentials,
91-
userSub,
92-
tokens
93-
)
9483
private var mockAuth = mock(AuthCategory::class.java)
9584

96-
9785
@Before
9886
fun setup() {
9987
plugin = AuthCognito(AuthCognitoHubEventStreamHandler(), mock(Activity::class.java))
@@ -688,18 +676,13 @@ class AmplifyAuthCognitoPluginTest {
688676
fun getCurrentUser_returnsSuccess() {
689677
// Arrange
690678
doAnswer { invocation: InvocationOnMock ->
691-
plugin.prepareUserResult(mockResult, AuthUser("username", "userSub"))
692-
null as Void?
693-
}.`when`(mockAuth).currentUser
694-
695-
doAnswer { invocation: InvocationOnMock ->
696-
plugin.prepareCognitoSessionResult(mockResult, mockSession)
679+
plugin.prepareUpdatePasswordResult(mockResult)
697680
null as Void?
698-
}.`when`(mockAuth).fetchAuthSession(any(), any())
681+
}.`when`(mockAuth).getCurrentUser()
699682

700683
val data: HashMap<*, *> = hashMapOf(
701-
"username" to "username",
702-
"userSub" to "userSub"
684+
"username" to "username",
685+
"userSub" to "userSub"
703686
)
704687
val arguments: HashMap<String, Any> = hashMapOf("data" to data)
705688
val call = MethodCall("getCurrentUser", arguments)
@@ -740,6 +723,18 @@ class AmplifyAuthCognitoPluginTest {
740723

741724
@Test
742725
fun fetchSession_returnsSuccess() {
726+
val id = AuthSessionResult.success("id")
727+
val awsCredentials: AuthSessionResult<AWSCredentials> = AuthSessionResult.success(BasicAWSCredentials("access", "secret"))
728+
val userSub = AuthSessionResult.success("sub")
729+
val tokens = AuthSessionResult.success(AWSCognitoUserPoolTokens("access", "id", "refresh"))
730+
val mockSession = AWSCognitoAuthSession(
731+
true,
732+
id,
733+
awsCredentials,
734+
userSub,
735+
tokens
736+
)
737+
743738
// Arrange
744739
doAnswer { invocation: InvocationOnMock ->
745740
plugin.prepareCognitoSessionResult(mockResult, mockSession)

packages/amplify_core/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ android {
6161

6262
dependencies {
6363
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64-
implementation 'com.amplifyframework:core:1.25.1'
64+
implementation 'com.amplifyframework:core:1.24.1'
6565
implementation 'com.google.code.gson:gson:2.8.6'
6666
testImplementation 'junit:junit:4.13.2'
6767
testImplementation 'org.mockito:mockito-core:3.10.0'

packages/amplify_datastore/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ android {
5757

5858
dependencies {
5959
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
60-
implementation "com.amplifyframework:aws-datastore:1.25.1"
61-
implementation "com.amplifyframework:aws-api-appsync:1.25.1"
60+
implementation "com.amplifyframework:aws-datastore:1.24.1"
61+
implementation "com.amplifyframework:aws-api-appsync:1.24.1"
6262
testImplementation 'junit:junit:4.13.2'
6363
testImplementation 'org.mockito:mockito-core:3.10.0'
6464
testImplementation 'org.mockito:mockito-inline:3.10.0'

packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterModelFieldType.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ data class FlutterModelFieldType(val map: Map<String, Any>) {
5959
return when (fieldType) {
6060
"string" -> String::class.java
6161
"int" -> Integer::class.java
62-
"double" -> Double::class.javaObjectType
62+
"double" -> Double::class.java
6363
"date" -> Temporal.Date::class.java
6464
"dateTime" -> Temporal.DateTime::class.java
6565
"time" -> Temporal.Time::class.java
6666
"timestamp" -> Temporal.Timestamp::class.java
67-
"bool" -> Boolean::class.javaObjectType
67+
"bool" -> Boolean::class.java
6868
"enumeration" -> String::class.java
6969
"model" -> Model::class.java
7070
"collection" -> List::class.java

packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/SchemaData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ val allTypeModelSchema = ModelSchema.builder()
266266
"floatType" to
267267
ModelField.builder()
268268
.name("floatType")
269-
.javaClassForValue(Double::class.javaObjectType)
269+
.javaClassForValue(Double::class.java)
270270
.targetType("Double")
271271
.isRequired(true)
272272
.isArray(false)
273273
.build(),
274274
"boolType" to
275275
ModelField.builder()
276276
.name("boolType")
277-
.javaClassForValue(Boolean::class.javaObjectType)
277+
.javaClassForValue(Boolean::class.java)
278278
.targetType("Boolean")
279279
.isRequired(true)
280280
.isArray(false)

packages/amplify_flutter/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ android {
5858

5959
dependencies {
6060
api amplifyCore
61-
implementation 'com.amplifyframework:core:1.25.1'
61+
implementation 'com.amplifyframework:core:1.24.1'
6262
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6363
testImplementation 'junit:junit:4.13.2'
6464
testImplementation 'org.mockito:mockito-core:3.10.0'
6565
testImplementation 'org.mockito:mockito-inline:3.10.0'
6666
testImplementation 'androidx.test:core:1.3.0'
6767
testImplementation 'org.robolectric:robolectric:4.3.1'
6868
testImplementation 'com.google.code.gson:gson:2.8.6'
69-
testImplementation 'com.amplifyframework:aws-auth-cognito:1.25.1'
69+
testImplementation 'com.amplifyframework:aws-auth-cognito:1.24.1'
7070
}

0 commit comments

Comments
 (0)