fix(auth): pageAccessRoutes 부서 조회에 sso_users fallback 추가
workers 테이블에 없는 사용자(55명 중 45명)의 department_id가 0이 되어 부서 권한 매칭 실패 → 모든 페이지 접근 차단되던 문제. COALESCE(w.department_id, su.department_id) fallback 적용. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -69,9 +69,12 @@ router.get('/users/:userId/page-access', requireAuth, async (req, res) => {
|
|||||||
return res.json({ success: true, data: { user, pageAccess } });
|
return res.json({ success: true, data: { user, pageAccess } });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 사용자의 부서 조회
|
// 사용자의 부서 조회 (workers 우선, 없으면 sso_users fallback)
|
||||||
const [workerRows] = await db.query(`
|
const [workerRows] = await db.query(`
|
||||||
SELECT w.department_id FROM workers w WHERE w.user_id = ?
|
SELECT COALESCE(w.department_id, su2.department_id, 0) AS department_id
|
||||||
|
FROM sso_users su2
|
||||||
|
LEFT JOIN workers w ON su2.user_id = w.user_id
|
||||||
|
WHERE su2.user_id = ?
|
||||||
`, [userId]);
|
`, [userId]);
|
||||||
const departmentId = workerRows[0]?.department_id || 0;
|
const departmentId = workerRows[0]?.department_id || 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user