This article demonstrates how users can reset their password within the app using Supabase authentication, even without sending a reset password link via email. The solution targets users who are already logged in and wish to change their password for security or other reasons.
Supabase is an open-source Backend-as-a-Service (BaaS) platform that offers a scalable backend for building web and mobile applications. It provides developers with tools to set up a complete backend without manually configuring databases or authentication systems. Supabase is often described as an alternative to Google Firebase, but with a stronger focus on open-source technologies and relational databases like PostgreSQL.
%20(3).png)
Follow the steps below to set up your Supabase project:
Project URL and API Key (usually the anon public key). You'll need these to configure the client-side.%20(6).png)
FlutterFlow is a low-code development platform built on top of Flutter, Google's open-source UI toolkit for building natively compiled applications for mobile, web, and desktop from a single codebase.
Follow the steps below to set up your FlutterFlow project:

%20(7).png)
.png)
.png)
// 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!
Future<bool> resetPassword(
BuildContext context,
String email,
String apiUrl,
String serviceRoleKey,
String newPassword,
String oldPassword,
) async {
// Add your function code here!
final supabase = SupabaseClient(apiUrl, serviceRoleKey);
try {
// Step 1: Authenticate user with old password
final response = await supabase.auth.signInWithPassword(
email: email,
password: oldPassword,
);
// Step 2: Update password if authentication is successful
await supabase.auth.updateUser(
UserAttributes(password: newPassword),
);
_showAlert(context, 'Success', 'Password updated successfully');
return true;
} on AuthException catch (e) {
_showAlert(context, 'Error',
e.statusCode == '400' ? 'Invalid old password' : e.message);
return false;
}
}
void _showAlert(BuildContext context, String title, String message) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: Text(message),
actions: <Widget>[
TextButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop(); // Close the dialog
},
),
],
);
},
);
}
signInWithPassword method.updateUser method.This method ensures that the password reset occurs directly within the app, providing a smooth and secure experience without requiring external email communication.
By combining Supabase Authentication with FlutterFlow, you can provide users with a secure and seamless way to reset their passwords directly within the app—without relying on email reset links. By verifying the user's existing password before allowing changes, this approach enhances security and prevents unauthorized access.
With a clear UI flow and proper error handling, this method simplifies password management while delivering a better user experience and a more secure authentication system.
