Overview
Thereset-password function resets a member’s password to a default value and flags their account to require a password change on their next login. This is useful for account recovery or when a member forgets their password.
Endpoint
This is a Supabase Edge Function that requires service role authentication.
Request Body
The unique identifier of the user whose password you want to reset. This is the user’s ID from the authentication system.
Response
Returns
true if the password reset was successful.Behavior
The function performs the following operations:- Validates user_id: Ensures a user_id is provided in the request
- Resets password: Updates the user’s password to the default value (
12345678) using the Supabase Auth Admin API - Flags for password change: Sets
force_password_change: truein the user’s profile to require a password change on next login
Security Considerations
- The password is reset to a known default value (
12345678) - The
force_password_changeflag ensures the user must change this temporary password - The profile update for
force_password_changeis non-blocking - if it fails, the password reset still succeeds
Example Request
Example Response
Error Response
If an error occurs, you’ll receive a response with status 400:Common Use Cases
- Password recovery: Help members who have forgotten their passwords
- Account lockout resolution: Reset passwords for locked accounts
- Administrative password resets: Manually reset passwords as needed by gym staff
- Bulk password resets: Reset passwords for multiple users programmatically
Implementation Example
Here’s how you might implement a password reset flow in your application:If the
force_password_change flag fails to update in the profile table, the function will log a warning but still return success. The password reset itself is the critical operation and is not affected by this non-blocking profile update.