mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-02 18:43:53 +00:00
show user idp in devices
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { z } from "zod";
|
||||
import { db, olms, users } from "@server/db";
|
||||
import { db, idp, idpOidcConfig, olms, users } from "@server/db";
|
||||
import { clients, currentFingerprint } from "@server/db";
|
||||
import { eq, and } from "drizzle-orm";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import response from "@server/lib/response";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
import createHttpError from "http-errors";
|
||||
@@ -236,6 +236,9 @@ export type GetClientResponse = NonNullable<
|
||||
lastSeen: number | null;
|
||||
} | null;
|
||||
posture: PostureData | null;
|
||||
userType: string | null;
|
||||
idpName: string | null;
|
||||
idpVariant: string | null;
|
||||
};
|
||||
|
||||
registry.registerPath({
|
||||
@@ -337,6 +340,30 @@ export async function getClient(
|
||||
: maskPostureDataWithPlaceholder(rawPosture)
|
||||
: null;
|
||||
|
||||
let userType: string | null = null;
|
||||
let idpName: string | null = null;
|
||||
let idpVariant: string | null = null;
|
||||
|
||||
if (client.clients.userId) {
|
||||
const [idpRow] = await db
|
||||
.select({
|
||||
userType: users.type,
|
||||
idpName: idp.name,
|
||||
idpVariant: idpOidcConfig.variant
|
||||
})
|
||||
.from(users)
|
||||
.leftJoin(idp, eq(users.idpId, idp.idpId))
|
||||
.leftJoin(idpOidcConfig, eq(idpOidcConfig.idpId, idp.idpId))
|
||||
.where(eq(users.userId, client.clients.userId))
|
||||
.limit(1);
|
||||
|
||||
if (idpRow) {
|
||||
userType = idpRow.userType;
|
||||
idpName = idpRow.idpName;
|
||||
idpVariant = idpRow.idpVariant;
|
||||
}
|
||||
}
|
||||
|
||||
const data: GetClientResponse = {
|
||||
...client.clients,
|
||||
name: clientName,
|
||||
@@ -347,7 +374,10 @@ export async function getClient(
|
||||
userName: client.user?.name ?? null,
|
||||
userUsername: client.user?.username ?? null,
|
||||
fingerprint: fingerprintData,
|
||||
posture: postureData
|
||||
posture: postureData,
|
||||
userType,
|
||||
idpName,
|
||||
idpVariant
|
||||
};
|
||||
|
||||
return response<GetClientResponse>(res, {
|
||||
|
||||
Reference in New Issue
Block a user