Control de modo editor/admin produccion/local
This commit is contained in:
@@ -18,6 +18,13 @@ import { fetchProjectInfo } from "./localClient.js";
|
||||
const DEFAULT_ROLE = 'developer';
|
||||
const FORGE_INTERNAL_URL = process.env.ACAI_FORGE_WEB_URL || "http://web:80";
|
||||
|
||||
const resolveEffectiveRole = (baseRole) => {
|
||||
if (process.env.ACAI_ROLE_OVERRIDE) return process.env.ACAI_ROLE_OVERRIDE;
|
||||
if (process.env.ACAI_MODE_OVERRIDE === "production") return "editor";
|
||||
if (process.env.ACAI_MODE === "production") return "editor";
|
||||
return baseRole || DEFAULT_ROLE;
|
||||
};
|
||||
|
||||
|
||||
// Session-based credentials storage (ephemeral, per-session)
|
||||
export const sessionCredentials = new Map();
|
||||
@@ -99,7 +106,7 @@ const readProjectAcaiFallback = () => {
|
||||
tokenHash: data.tokenHash || process.env.ACAI_TOKEN_HASH || null,
|
||||
mode,
|
||||
profileName: "acai-file",
|
||||
role: DEFAULT_ROLE,
|
||||
role: resolveEffectiveRole(data.role),
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(`[Credentials] Failed to read .acai fallback: ${error.message}`);
|
||||
@@ -136,7 +143,7 @@ const resolveLocalProjectFallback = async () => {
|
||||
tokenHash: info.tokenHash || process.env.ACAI_TOKEN_HASH || null,
|
||||
mode,
|
||||
profileName: "project-info",
|
||||
role: DEFAULT_ROLE,
|
||||
role: resolveEffectiveRole(info.role),
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -279,7 +286,7 @@ export const getSessionCredentials = async (sessionId, inlineCredentials = null)
|
||||
forge_host: process.env.ACAI_FORGE_HOST || null,
|
||||
tokenHash: process.env.ACAI_TOKEN_HASH || null,
|
||||
profileName: 'default',
|
||||
role: 'developer', // Env fallback = local dev, full access
|
||||
role: resolveEffectiveRole('developer'), // Env fallback = local dev, full access
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user