Files
vf_react/src/views/AgentChat/neuratalk/lib/auth-override.ts
2025-11-22 09:57:30 +08:00

37 lines
929 B
TypeScript

// lib/auth-override.ts - 临时覆盖权限检查(用于测试)
export interface AuthOverride {
enabled: boolean;
forceAuth?: boolean;
forceSubscription?: boolean;
mockUser?: any;
}
// 开发/测试模式下可以覆盖权限
export const authOverride: AuthOverride = {
enabled: true, // 启用覆盖
forceAuth: true, // 强制认证通过
forceSubscription: true, // 强制订阅权限通过
mockUser: {
id: 'max-user',
username: 'Max User',
email: 'max@valuefrontier.cn',
subscription_tier: 'max'
}
};
export function applyAuthOverride(authInfo: any) {
if (!authOverride.enabled) return authInfo;
if (authOverride.forceAuth) {
authInfo.isAuthenticated = true;
authInfo.user = authOverride.mockUser || authInfo.user;
}
if (authOverride.forceSubscription) {
authInfo.canAccessChat = true;
}
console.log('Auth override applied:', authInfo);
return authInfo;
}