Skip to content

Instantly share code, notes, and snippets.

@salihgueler
Created August 26, 2022 15:02
Show Gist options
  • Save salihgueler/b6428295c10c10d60735145494f2837c to your computer and use it in GitHub Desktop.
Save salihgueler/b6428295c10c10d60735145494f2837c to your computer and use it in GitHub Desktop.
Future<void> _confirmUser() async {
try {
// (1)
final result = await Amplify.Auth.confirmSignUp(
username: widget.username!,
confirmationCode: _confirmationCodeController.text,
);
// (2)
setState(() {
_isLoading = false;
});
// (3)
if (result.isSignUpComplete && mounted) {
context.go('/sign-in');
}
// (4)
} on CodeMismatchException {
setState(() {
_isLoading = false;
_errorMessage = 'The confirmation code is wrong. Please enter it again.';
});
} on Exception catch(error) {
setState(() {
_isLoading = false;
_errorMessage = 'An unexpected error has happened. Check the logs for detail';
});
logger.error(error.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment