feat: Add comprehensive test data generator and enhance user management with initials
This commit is contained in:
@@ -11,11 +11,15 @@ export async function createUser({ name, username, password, role = 'user', is_a
|
||||
|
||||
const passwordHash = await bcrypt.hash(password, 12)
|
||||
const userId = randomBytes(16).toString('hex')
|
||||
|
||||
// Generate initials from name (e.g., "John Doe" -> "JD")
|
||||
const nameParts = name.trim().split(/\s+/)
|
||||
const initial = nameParts.map(part => part.charAt(0).toUpperCase()).join('')
|
||||
|
||||
const result = db.prepare(`
|
||||
INSERT INTO users (id, name, username, password_hash, role, is_active, can_be_assigned)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(userId, name, username, passwordHash, role, is_active ? 1 : 0, can_be_assigned ? 1 : 0)
|
||||
INSERT INTO users (id, name, username, password_hash, role, initial, is_active, can_be_assigned)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(userId, name, username, passwordHash, role, initial, is_active ? 1 : 0, can_be_assigned ? 1 : 0)
|
||||
|
||||
return db.prepare(`
|
||||
SELECT id, name, username, role, created_at, updated_at, last_login,
|
||||
|
||||
Reference in New Issue
Block a user