Back

Errors are not returned when logging in via createEmailPasswordSession

  • 0
  • Self Hosted
  • Flutter
skns
31 Aug, 2024, 16:36

I have a flutter app.

Appwrite version for the flutter client - appwrite client: 12.0.3, on the self-hosted server - Version 1.5.7.

When trying to log in with an error on an android device (for example, an invalid password), the error is returned, but if I want to get an error when logging in via an iOS device, the code freezes in the place that I indicated. Please help me

TypeScript
  Future<Session> createEmailSession(
      {required String email, required String password}) async {
    notifyListeners();

    try {

      //this line is stuck
      final session = await account.createEmailPasswordSession(
          email: email, password: password);
      //end

      _currentUser = await account.get();
      _status = AuthStatus.authenticated;
      return session;
    } finally {
      notifyListeners();
    }
  }

And here is the code that handles the exception:

TypeScript
  Future<void> signIn() async {
    if (loading) {
      return;
    }
    setState(() {
      loading = true;
    });

    await showLoadingDialog();

    try {

      //here
      await user.createEmailSession(
        email: emailTextController.text,
        password: passwordTextController.text,
      );
      //end

      showSnackbar('Success login');
      context.pushReplacement('/');
    } on AppwriteException catch (e) {
      showAlert('Error', e.message.toString());
    } finally {
      Navigator.pop(context);
      setState(() {
        loading = false;
      });
    }
  }
TL;DR
Errors are not being returned when logging in via `createEmailPasswordSession` in a Flutter app using Appwrite. The issue seems to occur on iOS devices. The code freezes when trying to get an error message. **Solution:** The problem might be related to the version compatibility between the Flutter client and the self-hosted server. Check if updating the Appwrite client or server to the latest versions resolves the issue. Additionally, ensure error handling is properly implemented in the code.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more