1
0
forked from baron/baron-sso

orgfront refresh token 관리 추가

This commit is contained in:
2026-06-18 08:00:57 +09:00
parent 5f3167a503
commit 33249eb229
32 changed files with 867 additions and 337 deletions

View File

@@ -134,6 +134,28 @@ export function buildOrgPickerTree({
usersBySlug.set(slug, list);
}
const exposeAllRoots = rootTenantId?.trim().toLowerCase() === "all";
const tree = buildTenantFullTree(visibleTenants);
if (exposeAllRoots) {
const rootNodes = tree.subTree.filter((node) => node.type !== "USER_GROUP");
const companies = rootNodes.flatMap((root) =>
orderHanmacFamilyChildren(root, root.children).filter(
(node) => node.type === "COMPANY",
),
);
return {
roots: rootNodes.map((node) => tenantToPickerNode(node, usersBySlug)),
companies: companies.map((company) => ({
id: company.id,
name: company.name,
companyGroupTenantId: getCompanyGroupId(company, tenants),
})),
companyGroupId: "all",
};
}
const companyGroup =
findTenantByRef(visibleTenants, rootTenantId) ??
visibleTenants.find(isHanmacFamilyCompanyGroup) ??
@@ -144,10 +166,7 @@ export function buildOrgPickerTree({
const { currentBase } = buildTenantFullTree(visibleTenants, companyGroup.id);
const groupNode =
currentBase ??
buildTenantFullTree(visibleTenants).subTree.find(
(node) => node.id === companyGroup.id,
);
currentBase ?? tree.subTree.find((node) => node.id === companyGroup.id);
if (!groupNode) return { roots: [], companies: [], companyGroupId: "" };

View File

@@ -9,6 +9,8 @@ export type OrgPickerSelection = {
id: string;
name: string;
email?: string;
rootTenantName?: string;
leafTenantName?: string;
};
export type OrgPickerResult = {

View File

@@ -40,13 +40,24 @@ function canToggleNode(
);
}
function toSelection(node: OrgPickerTreeNode): OrgPickerSelection {
function toSelection(
node: OrgPickerTreeNode,
ancestors: OrgPickerTreeNode[] = [],
): OrgPickerSelection {
if (node.type === "user") {
const tenantAncestors = ancestors.filter(
(ancestor) => ancestor.type === "tenant",
);
const rootTenant = tenantAncestors[0];
const leafTenant = tenantAncestors[tenantAncestors.length - 1];
return {
type: node.type,
id: node.id,
name: node.name,
email: node.user?.email,
rootTenantName: rootTenant?.name,
leafTenantName: leafTenant?.name,
};
}
@@ -68,27 +79,49 @@ function collectSelectedNodes({
includeDescendants: boolean;
select: OrgPickerSelectableType;
}) {
const selected = new Map<string, OrgPickerTreeNode>();
const visit = (node: OrgPickerTreeNode) => {
const selected = new Map<
string,
{ node: OrgPickerTreeNode; ancestors: OrgPickerTreeNode[] }
>();
const addNode = (node: OrgPickerTreeNode, ancestors: OrgPickerTreeNode[]) => {
if (canSelectNode(node, select)) {
selected.set(nodeKey(node), { node, ancestors });
}
};
const addDescendants = (
node: OrgPickerTreeNode,
ancestors: OrgPickerTreeNode[],
) => {
const visitDescendant = (
descendant: OrgPickerTreeNode,
descendantAncestors: OrgPickerTreeNode[],
) => {
addNode(descendant, descendantAncestors);
for (const child of descendant.children) {
visitDescendant(child, [...descendantAncestors, descendant]);
}
};
for (const child of node.children) {
visitDescendant(child, [...ancestors, node]);
}
};
const visit = (node: OrgPickerTreeNode, ancestors: OrgPickerTreeNode[]) => {
const key = nodeKey(node);
if (selectedKeys.has(key)) {
if (canSelectNode(node, select)) {
selected.set(key, node);
}
addNode(node, ancestors);
if (includeDescendants && node.type === "tenant") {
for (const descendant of flattenDescendants(node)) {
if (canSelectNode(descendant, select)) {
selected.set(nodeKey(descendant), descendant);
}
}
addDescendants(node, ancestors);
}
}
for (const child of node.children) visit(child);
for (const child of node.children) visit(child, [...ancestors, node]);
};
for (const root of roots) visit(root);
return Array.from(selected.values()).map(toSelection);
for (const root of roots) visit(root, []);
return Array.from(selected.values()).map(({ node, ancestors }) =>
toSelection(node, ancestors),
);
}
function collectCheckedKeys({