Skip to content

Instantly share code, notes, and snippets.

@salihgueler
Created August 26, 2022 15:15
Show Gist options
  • Save salihgueler/cf5aa8876339b686c18f0af5bdf063cf to your computer and use it in GitHub Desktop.
Save salihgueler/cf5aa8876339b686c18f0af5bdf063cf to your computer and use it in GitHub Desktop.
Future<void> _confirmEmailAddress() async {
try {
await Amplify.Auth.confirmUserAttribute(
userAttributeKey: CognitoUserAttributeKey.email,
confirmationCode: _confirmationCodeController.text,
);
setState(() {
_isLoading = false;
});
if(mounted) {
context.go('/home');
}
} 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