Lower account password minimum to eight characters

This commit is contained in:
2026-10-04 09:29:55 -04:00
parent e5c0fda1ed
commit 95cf7dd36f
7 changed files with 18 additions and 17 deletions
+5 -4
View File
@@ -7,7 +7,7 @@ vi.setConfig({ testTimeout: 20_000, hookTimeout: 20_000 });
import { newFixture, type Fixture } from '../helpers/fixture.js';
import type { UserRole } from '../../src/lib/auth.js';
const password = 'correct horse battery staple';
const password = 'testpass';
const replacement = 'another long secret passphrase';
const setupToken = 'ec_setup_test_0123456789abcdef0123456789abcdef';
let passwordHash: string;
@@ -106,10 +106,11 @@ describe('password storage and verification', () => {
it('bounds password length by Unicode characters and rejects invalid inputs before hashing', async () => {
const { validatePassword, hashPassword, verifyPassword } = await import('../../src/lib/server/auth/passwords.js');
for (const value of [undefined, null, 123, '', 'short password', 'a'.repeat(129)]) {
await expect(hashPassword(value)).rejects.toThrow('15 and 128');
for (const value of [undefined, null, 123, '', 'a'.repeat(7), '🦊'.repeat(7), 'a'.repeat(129)]) {
await expect(hashPassword(value)).rejects.toThrow('8 and 128');
}
expect(validatePassword('🦊'.repeat(15))).toBe('🦊'.repeat(15));
expect(validatePassword('a'.repeat(8))).toBe('a'.repeat(8));
expect(validatePassword('🦊'.repeat(8))).toBe('🦊'.repeat(8));
expect(validatePassword('a'.repeat(128))).toHaveLength(128);
expect(await verifyPassword('a'.repeat(129), passwordHash)).toBe(false);
});