fix: auth middleware, JWT_SECRET env guard, and password reset token lookup

This commit is contained in:
Azriel
2026-05-10 15:23:34 +00:00
parent e633d693da
commit e10b387be6
4 changed files with 45 additions and 20 deletions

View File

@@ -5,12 +5,14 @@ export async function up(knex: Knex): Promise<void> {
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
table.uuid('user_id').notNullable().references('id').inTable('users').onDelete('CASCADE');
table.string('token_hash', 255).notNullable();
table.string('lookup_hash', 64).notNullable();
table.timestamp('expires_at', { useTz: true }).notNullable();
table.timestamp('used_at', { useTz: true }).nullable();
table.timestamp('created_at', { useTz: true }).defaultTo(knex.fn.now());
});
await knex.raw(`CREATE INDEX idx_prt_user_id ON password_reset_tokens (user_id)`);
await knex.raw(`CREATE UNIQUE INDEX idx_prt_lookup_hash ON password_reset_tokens (lookup_hash)`);
}
export async function down(knex: Knex): Promise<void> {