supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
656 stars 154 forks source link

AuthWeakPasswordException causes an unhandled exception #903

Closed sibiramer closed 1 month ago

sibiramer commented 1 month ago

Describe the bug A weak password will result in an unhandled exception:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'List<String>'
GotrueFetch._handleError (package:gotrue/src/fetch.dart:61:39)

To Reproduce Steps to reproduce the behavior:

Use this widget that calls the auth flow:

final supabase = Supabase.instance.client;

class Home extends StatefulWidget {
  const Home({super.key});

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  String _email = "testemail@example.com";
  String _password = "test123";

  Future _register() async {
    AuthResponse res;
    try {
      res = await supabase.auth.signUp(email: _email, password: _password);
    } on AuthWeakPasswordException catch (e) {
      print("Weak password: $e");
      return;
    } on AuthApiException catch (e) {
      print("API Auth exception: $e");
      return;
    } on AuthException catch (e) {
      print("Auth exception: $e");
      return;
    }
    print("Success: $res");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: IconButton(
          icon: Icon(Icons.add_box_outlined),
          onPressed: _register,
        ),
      ),
    );
  }
}

Expected behavior I expect to catch the Exception in the first on AuthWeakPasswordException catch (e) block. However, an unhandled exception is thrown.

Screenshots

Screenshot 2024-04-24 at 9 10 50 PM

Version (please complete the following information):

❯ dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client"
├── supabase_flutter 2.5.1
│   ├── supabase 2.1.1
│   │   ├── functions_client 2.0.0
│   │   ├── gotrue 2.6.0
│   │   ├── postgrest 2.1.1
│   │   ├── realtime_client 2.0.4
│   │   ├── storage_client 2.0.1
dshukertjr commented 1 month ago

Closing as duplicate of #891. A fixed version will be released soon.