File tree 2 files changed +23
-1
lines changed
aws-auth-cognito/src/main/java/com/amplifyframework
statemachine/codegen/states
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1880,6 +1880,7 @@ internal class RealAWSCognitoAuthPlugin(
1880
1880
1881
1881
private fun _signOut (sendHubEvent : Boolean = true, onComplete : Consumer <AuthSignOutResult >) {
1882
1882
val token = StateChangeListenerToken ()
1883
+ var cancellationException: UserCancelledException ? = null
1883
1884
authStateMachine.listen(
1884
1885
token,
1885
1886
{ authState ->
@@ -1921,6 +1922,18 @@ internal class RealAWSCognitoAuthPlugin(
1921
1922
)
1922
1923
)
1923
1924
}
1925
+ authNState is AuthenticationState .SigningOut -> {
1926
+ val state = authNState.signOutState
1927
+ if (state is SignOutState .Error && state.exception is UserCancelledException ) {
1928
+ cancellationException = state.exception
1929
+ }
1930
+ }
1931
+ authNState is AuthenticationState .SignedIn && cancellationException != null -> {
1932
+ authStateMachine.cancel(token)
1933
+ cancellationException?.let {
1934
+ onComplete.accept(AWSCognitoAuthSignOutResult .FailedSignOut (it))
1935
+ }
1936
+ }
1924
1937
else -> {
1925
1938
// No - op
1926
1939
}
Original file line number Diff line number Diff line change 15
15
16
16
package com.amplifyframework.statemachine.codegen.states
17
17
18
+ import com.amplifyframework.auth.cognito.exceptions.service.UserCancelledException
18
19
import com.amplifyframework.auth.cognito.isAuthEvent
19
20
import com.amplifyframework.auth.cognito.isSignOutEvent
20
21
import com.amplifyframework.statemachine.State
@@ -86,7 +87,15 @@ internal sealed class SignOutState : State {
86
87
}
87
88
is SignOutEvent .EventType .UserCancelled -> {
88
89
val action = signOutActions.userCancelledAction(signOutEvent)
89
- StateResolution (Error (Exception (" User Cancelled" )), listOf (action))
90
+ StateResolution (
91
+ Error (
92
+ UserCancelledException (
93
+ " The user cancelled the sign-out attempt, so it did not complete." ,
94
+ " To recover: catch this error, and attempt the sign out again."
95
+ )
96
+ ),
97
+ listOf (action)
98
+ )
90
99
}
91
100
else -> defaultResolution
92
101
}
You can’t perform that action at this time.
0 commit comments