Each user can now have ivanti_first_name and ivanti_last_name configured in User Management. The workflow sync queries all configured Ivanti identities and fetches workflows for each. The GET endpoint filters workflows to only show those belonging to the logged-in user's Ivanti identity. Users without an Ivanti identity see all workflows (admin fallback). If no users have identities configured, falls back to IVANTI_FIRST_NAME/ IVANTI_LAST_NAME from .env for backward compatibility. Changes: - Migration adds ivanti_first_name, ivanti_last_name to users table - Users route accepts and returns the new fields - User Management UI has Ivanti Identity input fields - Workflow sync iterates all configured user identities - Workflow GET filters by logged-in user's identity
32 lines
948 B
JavaScript
32 lines
948 B
JavaScript
#!/usr/bin/env node
|
|
// Migration: Add ivanti_first_name and ivanti_last_name to users table
|
|
// Allows per-user Ivanti identity for workflow filtering.
|
|
|
|
const pool = require('../db');
|
|
|
|
async function run() {
|
|
console.log('Adding Ivanti identity columns to users table...');
|
|
try {
|
|
await pool.query(`
|
|
ALTER TABLE users
|
|
ADD COLUMN IF NOT EXISTS ivanti_first_name VARCHAR(100) DEFAULT NULL
|
|
`);
|
|
console.log('✓ ivanti_first_name column added (or already exists)');
|
|
|
|
await pool.query(`
|
|
ALTER TABLE users
|
|
ADD COLUMN IF NOT EXISTS ivanti_last_name VARCHAR(100) DEFAULT NULL
|
|
`);
|
|
console.log('✓ ivanti_last_name column added (or already exists)');
|
|
|
|
console.log('Migration complete.');
|
|
} catch (err) {
|
|
console.error('Migration failed:', err.message);
|
|
process.exit(1);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
run();
|