refactor: worker_id → user_id 전체 마이그레이션 (Phase 1-4)
sso_users.user_id를 단일 식별자로 통합. JWT에서 worker_id 제거, department_id/is_production 추가. 백엔드 15개 모델, 11개 컨트롤러, 4개 서비스, 7개 라우트, 프론트엔드 32+ JS/11+ HTML 변환. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,9 @@ function createTokenPayload(user) {
|
||||
id: user.user_id,
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
worker_id: user.worker_id || null,
|
||||
department_id: user.department_id || null,
|
||||
department_name: user.department_name || user.department || null,
|
||||
is_production: user.is_production || false,
|
||||
department: user.department,
|
||||
role: user.role,
|
||||
access_level: user.role,
|
||||
@@ -78,8 +80,10 @@ async function login(req, res, next) {
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
department: user.department,
|
||||
department_id: user.department_id || null,
|
||||
department_name: user.department_name || user.department || null,
|
||||
is_production: user.is_production || false,
|
||||
role: user.role,
|
||||
worker_id: user.worker_id || null,
|
||||
system_access: payload.system_access
|
||||
}
|
||||
});
|
||||
@@ -154,8 +158,10 @@ async function validate(req, res, next) {
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
department: user.department,
|
||||
department_id: user.department_id || null,
|
||||
department_name: user.department_name || user.department || null,
|
||||
is_production: user.is_production || false,
|
||||
role: user.role,
|
||||
worker_id: user.worker_id || null,
|
||||
system_access: {
|
||||
system1: user.system1_access,
|
||||
system2: user.system2_access,
|
||||
|
||||
@@ -84,7 +84,10 @@ async function hashPassword(password) {
|
||||
async function findByUsername(username) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
'SELECT * FROM sso_users WHERE username = ? AND is_active = TRUE',
|
||||
`SELECT s.*, d.department_id, d.department_name, d.is_production
|
||||
FROM sso_users s
|
||||
LEFT JOIN departments d ON s.department_id = d.department_id
|
||||
WHERE s.username = ? AND s.is_active = TRUE`,
|
||||
[username]
|
||||
);
|
||||
return rows[0] || null;
|
||||
@@ -93,7 +96,10 @@ async function findByUsername(username) {
|
||||
async function findById(userId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
'SELECT * FROM sso_users WHERE user_id = ?',
|
||||
`SELECT s.*, d.department_id, d.department_name, d.is_production
|
||||
FROM sso_users s
|
||||
LEFT JOIN departments d ON s.department_id = d.department_id
|
||||
WHERE s.user_id = ?`,
|
||||
[userId]
|
||||
);
|
||||
return rows[0] || null;
|
||||
|
||||
Reference in New Issue
Block a user