debug: 添加权限过滤日志定位问题
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -312,8 +312,15 @@ async function getVehicles(): Promise<Vehicle[]> {
|
|||||||
|
|
||||||
async function getVehiclesForUser(c: Context): Promise<Vehicle[]> {
|
async function getVehiclesForUser(c: Context): Promise<Vehicle[]> {
|
||||||
const all = await getVehicles();
|
const all = await getVehicles();
|
||||||
const user = c.get('user') as AuthUser | undefined;
|
// Hono 子路由 context 可能丢失变量,尝试多种方式获取
|
||||||
return user ? filterByPermission(all, user) : all;
|
const user = ((c as any).get?.('user') || (c as any).var?.user) as AuthUser | undefined;
|
||||||
|
if (user) {
|
||||||
|
const filtered = filterByPermission(all, user);
|
||||||
|
console.log(`[vehicles] permission: ${user.permissionLevel}, user: ${user.userName}, before: ${all.length}, after: ${filtered.length}`);
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
console.log('[vehicles] WARNING: no user in context, returning all');
|
||||||
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRegionCounts(vehicles: Vehicle[], regions: readonly string[]): Record<string, number> {
|
function getRegionCounts(vehicles: Vehicle[], regions: readonly string[]): Record<string, number> {
|
||||||
|
|||||||
Reference in New Issue
Block a user