createAccountWithEmailAndPassword method

Future<CuReSupabaseAuthResponse> createAccountWithEmailAndPassword(
  1. String email,
  2. String password,
  3. Map<String, dynamic> data
)

Implementation

Future<CuReSupabaseAuthResponse> createAccountWithEmailAndPassword(
  String email,
  String password,
  Map<String, dynamic> data,
) async {
  try {
    final supabase = Supabase.instance.client;
    final AuthResponse res = await supabase.auth.signUp(
      email: email,
      password: password,
      data: data,
    );
    final Session? session = res.session;
    final User? user = res.user;
    return CuReSupabaseAuthResponse(
      user: user,
      session: session,
      error: null,
    );
  } catch (e) {
    // ignore: avoid_print
    print('[Supabase CuRe Auth] Exception during account creation: $e');
    return CuReSupabaseAuthResponse(
      user: null,
      session: null,
      error: _getErrorMessage(e),
    );
  }
}