fix(web): remove identity simulation and stop sending X-User-ID
Product UI no longer switches sessions locally; API clients attach Bearer tokens only and LocalAuthClient stays test-only outside the prod bundle.
This commit is contained in:
@@ -1,137 +0,0 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Sparkles, ChevronUp, ChevronDown, Check, UserCheck } from 'lucide-react';
|
||||
import { UserProfile } from '../../types/docgov';
|
||||
|
||||
interface DevRoleSwitcherProps {
|
||||
env?: string;
|
||||
currentUser: UserProfile;
|
||||
allUsers: UserProfile[];
|
||||
onSwitchUser: (user: UserProfile) => void;
|
||||
}
|
||||
|
||||
export const DevRoleSwitcher: React.FC<DevRoleSwitcherProps> = ({
|
||||
env = 'dev',
|
||||
currentUser,
|
||||
allUsers,
|
||||
onSwitchUser,
|
||||
}) => {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
|
||||
// 严格环境红线:非 dev 环境绝对不渲染任何 DOM 内容
|
||||
if (env !== 'dev') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
bottom: '16px',
|
||||
right: '16px',
|
||||
zIndex: 50,
|
||||
fontFamily: 'var(--font-sans)',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: '280px',
|
||||
backgroundColor: 'var(--bg-panel, #131820)',
|
||||
borderRadius: '12px',
|
||||
border: '1px solid var(--border-strong)',
|
||||
boxShadow: 'var(--shadow-lg)',
|
||||
overflow: 'hidden',
|
||||
backdropFilter: 'blur(8px)',
|
||||
}}
|
||||
>
|
||||
{/* 折叠收起顶栏 */}
|
||||
<div
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
backgroundColor: 'var(--bg-subtle, #1A212C)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
cursor: 'pointer',
|
||||
borderBottom: expanded ? '1px solid var(--border)' : 'none',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>
|
||||
<Sparkles size={14} style={{ color: 'var(--amber-500)' }} />
|
||||
<span style={{ fontSize: '12px', fontWeight: 600, color: 'var(--text-strong)' }}>
|
||||
DEV 调试切人
|
||||
</span>
|
||||
<span
|
||||
style={{
|
||||
fontSize: '10px',
|
||||
padding: '1px 5px',
|
||||
borderRadius: '4px',
|
||||
backgroundColor: 'rgba(242, 169, 59, 0.15)',
|
||||
color: 'var(--amber-500)',
|
||||
fontWeight: 600,
|
||||
}}
|
||||
>
|
||||
DEV ONLY
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '4px', fontSize: '11px', color: 'var(--text-muted)' }}>
|
||||
<span style={{ color: 'var(--brand-500)', fontWeight: 600 }}>{currentUser.name}</span>
|
||||
{expanded ? <ChevronDown size={14} /> : <ChevronUp size={14} />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 展开的快速切换列表 */}
|
||||
{expanded && (
|
||||
<div
|
||||
style={{
|
||||
padding: '8px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '4px',
|
||||
maxHeight: '220px',
|
||||
overflowY: 'auto',
|
||||
backgroundColor: 'var(--bg-card, #151B25)',
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: '10px', color: 'var(--text-faint)', padding: '2px 4px' }}>
|
||||
点击一键切换身份,实测立项、指派与文档权限:
|
||||
</div>
|
||||
{allUsers.map((u) => {
|
||||
const isCurrent = u.id === currentUser.id;
|
||||
return (
|
||||
<button
|
||||
key={u.id}
|
||||
type="button"
|
||||
onClick={() => onSwitchUser(u)}
|
||||
style={{
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
padding: '6px 10px',
|
||||
borderRadius: '6px',
|
||||
fontSize: '12px',
|
||||
backgroundColor: isCurrent ? 'rgba(79, 107, 255, 0.12)' : 'transparent',
|
||||
border: isCurrent ? '1px solid rgba(79, 107, 255, 0.3)' : '1px solid transparent',
|
||||
color: isCurrent ? 'var(--brand-500)' : 'var(--text)',
|
||||
cursor: 'pointer',
|
||||
textAlign: 'left',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<UserCheck size={13} style={{ color: isCurrent ? 'var(--brand-500)' : 'var(--text-muted)' }} />
|
||||
<span style={{ fontWeight: isCurrent ? 600 : 400 }}>{u.name}</span>
|
||||
<span style={{ fontSize: '10px', color: 'var(--text-faint)' }}>({u.position})</span>
|
||||
</div>
|
||||
{isCurrent && <Check size={13} style={{ color: 'var(--brand-500)' }} />}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
Plus,
|
||||
Trash2,
|
||||
Check,
|
||||
UserCheck,
|
||||
Users,
|
||||
Key,
|
||||
Info,
|
||||
@@ -23,7 +22,6 @@ export interface SettingsModalProps {
|
||||
users: UserProfile[];
|
||||
currentUser: UserProfile;
|
||||
onUpdateUserRole: (userId: number, roleId: string) => void;
|
||||
onSwitchUser: (user: UserProfile) => void;
|
||||
}
|
||||
|
||||
const ALL_PERMISSION_ITEMS: {
|
||||
@@ -84,7 +82,6 @@ export const SettingsModal: FC<SettingsModalProps> = ({
|
||||
users,
|
||||
currentUser,
|
||||
onUpdateUserRole,
|
||||
onSwitchUser,
|
||||
}) => {
|
||||
const [activeTab, setActiveTab] = useState<'roles' | 'users'>('roles');
|
||||
const [selectedRoleId, setSelectedRoleId] = useState<string>(roles[0]?.id || 'role-admin');
|
||||
@@ -779,35 +776,11 @@ export const SettingsModal: FC<SettingsModalProps> = ({
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* 切换登录人按钮 */}
|
||||
{!isCurrent ? (
|
||||
<button
|
||||
onClick={() => {
|
||||
onSwitchUser(u);
|
||||
showSavedNotification();
|
||||
}}
|
||||
style={{
|
||||
padding: '6px 14px',
|
||||
borderRadius: '6px',
|
||||
border: '1px solid var(--brand-500)',
|
||||
backgroundColor: 'var(--brand-500)',
|
||||
color: '#fff',
|
||||
fontSize: '12px',
|
||||
fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '4px',
|
||||
}}
|
||||
>
|
||||
<UserCheck size={13} />
|
||||
<span>切换为此人登录</span>
|
||||
</button>
|
||||
) : (
|
||||
{isCurrent ? (
|
||||
<span style={{ fontSize: '12px', color: 'var(--brand-500)', fontWeight: 600, width: '120px', textAlign: 'center' }}>
|
||||
✓ 正在以此身份交互
|
||||
✓ 当前登录身份
|
||||
</span>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -17,10 +17,7 @@ interface UserProjectRightsModalProps {
|
||||
currentProjectTitle: string;
|
||||
deliverables: DeliverableItem[];
|
||||
activeDocId: string;
|
||||
allUsers?: UserProfile[];
|
||||
canAssignLead?: boolean;
|
||||
onSwitchUser?: (user: UserProfile) => void;
|
||||
allowDevSwitch?: boolean;
|
||||
onSelectDoc: (docId: string) => void;
|
||||
onRoleChangeForDoc?: (docId: string, role: DocPermissionRole) => void;
|
||||
}
|
||||
@@ -32,10 +29,7 @@ export const UserProjectRightsModal: FC<UserProjectRightsModalProps> = ({
|
||||
currentProjectTitle,
|
||||
deliverables,
|
||||
activeDocId,
|
||||
allUsers,
|
||||
canAssignLead = true,
|
||||
onSwitchUser,
|
||||
allowDevSwitch = true,
|
||||
onSelectDoc,
|
||||
onRoleChangeForDoc,
|
||||
}) => {
|
||||
@@ -567,33 +561,7 @@ export const UserProjectRightsModal: FC<UserProjectRightsModalProps> = ({
|
||||
justifyContent: 'space-between',
|
||||
}}
|
||||
>
|
||||
{allowDevSwitch && allUsers && allUsers.length > 0 ? (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>
|
||||
<span style={{ fontSize: '11px', color: 'var(--amber-400)', fontWeight: 600 }}>[DEV 调试切人]:</span>
|
||||
{allUsers.map((u) => {
|
||||
const isCurrent = u.id === currentUser.id;
|
||||
return (
|
||||
<button
|
||||
key={u.id}
|
||||
onClick={() => onSwitchUser?.(u)}
|
||||
style={{
|
||||
padding: '4px 10px',
|
||||
borderRadius: '4px',
|
||||
border: isCurrent ? '1px solid var(--brand-500)' : '1px solid var(--border)',
|
||||
backgroundColor: isCurrent ? 'var(--brand-500)' : 'var(--bg-panel, #131820)',
|
||||
color: isCurrent ? '#fff' : 'var(--text)',
|
||||
fontSize: '11px',
|
||||
fontWeight: isCurrent ? 600 : 400,
|
||||
cursor: 'pointer',
|
||||
transition: 'all 0.15s ease',
|
||||
}}
|
||||
>
|
||||
{u.name} ({u.position.slice(0, 4)})
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : <div />}
|
||||
<div />
|
||||
|
||||
<button
|
||||
onClick={onClose}
|
||||
|
||||
Reference in New Issue
Block a user