Feature request
Is your feature request related to a problem? Please describe.
When adding users to Supabase, the password is hashed on the database side as part of the createUser function. When seeding, that encryption can't be matched by bcrypt, resulting in an invalid password. Seeded users can't be used for manual testing.
Describe the solution you'd like
A way to access the postgres functions on the db instance, or ability to execute sql with the seed function:
const result = await seed.$db.query(`
INSERT INTO auth.users (
aud,
email,
encrypted_password,
role,
raw_app_meta_data
) VALUES (
$1,
$2,
crypt($3, gen_salt('bf')),
$4,
$5
) RETURNING *
`, [
'Seed Test User',
'seed-file@test.app',
'SeedTest1234',
'authenticated',
{
provider: 'email',
providers: ['email'],
claims_admin: true,
}
]);
return result.rows;
});
or
await seed.users([
{
aud: 'Seed Test User',
email: 'seed-file@test.app',
encrypted_password: seed.sql`crypt('SeedTest1234', gen_salt('bf'))`,
role: 'authenticated',
raw_app_meta_data: {
provider: 'email',
providers: ['email'],
claims_admin: true,
},
},
]);
Describe alternatives you've considered
- Passing an sql file to the
defineConfig function with some default users created with raw sql and make them available to the seed context
- Adding a migration to the db that checks if the password is encrypted, to try and mock the functionality of supabase directly on the db
- Creating a supabase client in the seed function, and adding the return values to the seed
ctx somehow
Feature request
Is your feature request related to a problem? Please describe.
When adding users to Supabase, the password is hashed on the database side as part of the
createUserfunction. When seeding, that encryption can't be matched by bcrypt, resulting in an invalid password. Seeded users can't be used for manual testing.Describe the solution you'd like
A way to access the postgres functions on the db instance, or ability to execute sql with the
seedfunction:Describe alternatives you've considered
defineConfigfunction with some default users created with raw sql and make them available to the seed contextctxsomehow