aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.31k stars 241 forks source link

Authenticator signIn does not throw any error #5276

Closed kamami closed 2 weeks ago

kamami commented 4 weeks ago

Description

I am calling state.signIn() with a custom button, but it does not throw any error I could fetch to show some feedback to the user.

Categories

Steps to Reproduce

  void submit() async {
    if (widget.state.formKey.currentState!.validate()) {

      try {

        await widget.state.signIn();

      } catch (e) {
        if (mounted) {

          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(
              content: Row(
                children: [
                  const Icon(
                    Icons.error_rounded,
                    color: Colors.white,
                  ),
                  const SizedBox(
                    width: 8,
                  ),
                  Expanded(child: Text(e.toString())),
                ],
              ),
              backgroundColor: Colors.redAccent,
            ),
          );
        }
      } finally {}
    }
  }

Screenshots

No response

Platforms

Flutter Version

3.24.0

Amplify Flutter Version

2.3.0

Deployment Method

Custom Pipeline

Schema

No response

khatruong2009 commented 4 weeks ago

Hi @kamami, thank you for submitting this issue. We will take a look at it and get back to you with any questions or updates.

khatruong2009 commented 3 weeks ago

Hi @kamami, this is expected behavior when calling signIn from the state machine. You could call await Amplify.Auth.signIn(state.username, state.password); which would return a future containing any sign in errors that you would have. This would also take care of the state machine moving forward as well. If you have MFA enabled, you may have to manually progress the state.

NikaHsn commented 3 weeks ago

@kamami Let us know if you have any further questions. Otherwise I will close this out since there isn't any action required in Amplify.

github-actions[bot] commented 2 weeks ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.