File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
aws-auth-cognito/src/main/java/com/amplifyframework
statemachine/codegen/states Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1880,6 +1880,7 @@ internal class RealAWSCognitoAuthPlugin(
18801880
18811881 private fun _signOut (sendHubEvent : Boolean = true, onComplete : Consumer <AuthSignOutResult >) {
18821882 val token = StateChangeListenerToken ()
1883+ var cancellationException: UserCancelledException ? = null
18831884 authStateMachine.listen(
18841885 token,
18851886 { authState ->
@@ -1921,6 +1922,18 @@ internal class RealAWSCognitoAuthPlugin(
19211922 )
19221923 )
19231924 }
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+ }
19241937 else -> {
19251938 // No - op
19261939 }
Original file line number Diff line number Diff line change 1515
1616package com.amplifyframework.statemachine.codegen.states
1717
18+ import com.amplifyframework.auth.cognito.exceptions.service.UserCancelledException
1819import com.amplifyframework.auth.cognito.isAuthEvent
1920import com.amplifyframework.auth.cognito.isSignOutEvent
2021import com.amplifyframework.statemachine.State
@@ -86,7 +87,15 @@ internal sealed class SignOutState : State {
8687 }
8788 is SignOutEvent .EventType .UserCancelled -> {
8889 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+ )
9099 }
91100 else -> defaultResolution
92101 }
You can’t perform that action at this time.
0 commit comments