Creating Users from an Admin Account - createSupabaseUser

Actions & Logic

Hi Everyone!

I badly need help and I have been really stuck.

My problem is just the same with this but I need it for Supabase.

Basically, I have an app where only the admin has access to the creation of users. I have tried creating via front end but the admin get's signed out and the user being created gets logged in.

What have you tried so far?

I have tried researching and implementing the function but I get errors.

Below is my code:

// Automatic FlutterFlow imports import '/backend/supabase/supabase.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/custom_code/actions/index.dart'; // Imports other custom actions import '/flutter_flow/custom_functions.dart'; // Imports custom functions import 'package:flutter/material.dart'; // Begin custom action code // DO NOT REMOVE OR MODIFY THE CODE ABOVE! // createSupabaseUser create user authentication using email and password for supabase // Import necessary packages import 'package:supabase/supabase.dart'; // Define function to create user authentication using email and password Future createSupabaseUser( BuildContext context, String email, String password, ) async { final supabase = SupaFlow.client; // Call Supabase API to create user final response = await supabase.auth.signUp(email, password); // Check if user creation was successful if (response.error != null) { // Display error message ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(response.error!.message), backgroundColor: Colors.red, ), ); } else { // Display success message ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('User created successfully!'), backgroundColor: Colors.green, ), ); } }

Did you check FlutterFlow's Documentation for this topic?
Yes
2
11 replies