fix(web): restore admin password reset in user governance
T20-F4-A removed the working reset button after the F4-B endpoint was already live. Restore the entry so admins can issue a one-time random temp password.
This commit is contained in:
@@ -180,9 +180,36 @@ export const UsersSection: React.FC<UsersSectionProps> = ({ currentUser, onRefre
|
||||
}
|
||||
};
|
||||
|
||||
// T20-F4-A:管理员重置密码已被移除(端点未开通,F4-B 需产品选型)。
|
||||
// 保留函数体注释以记录历史行为;重新启用需在 F4-B 实施时恢复按钮与服务端端点。
|
||||
// const handleResetUserPassword = async (user: UserAccount) => { ... };
|
||||
// 管理员重置密码:POST /api/v1/admin/users/{id}/reset-password(T20-F4-B,已开通)。
|
||||
// T20-F4-A 误判端点未开通并删掉入口;本任务恢复。服务端生成一次性随机临时口令并强制下次登录改密。
|
||||
const handleResetUserPassword = async (user: UserAccount) => {
|
||||
if (
|
||||
!window.confirm(
|
||||
`确定要重置【${user.name}】的密码吗?系统将生成一次性临时口令,该用户下次登录将被强制改密。临时口令仅展示一次。`,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await authClient.adminResetPassword(user.id);
|
||||
try {
|
||||
await refreshUsers();
|
||||
} catch {
|
||||
// password already reset; continue to show temp password
|
||||
}
|
||||
const copied = window.prompt(
|
||||
`已重置【${user.name}】密码。请立即复制临时口令(关闭后不可再查看):`,
|
||||
result.tempPassword,
|
||||
);
|
||||
if (copied === null) {
|
||||
showNotification('success', '密码已重置;请手动记下上方弹出的临时口令');
|
||||
} else {
|
||||
showNotification('success', '密码已重置,已标记首次登录强制改密');
|
||||
}
|
||||
} catch (err: any) {
|
||||
showNotification('error', err.message || '重置密码失败');
|
||||
}
|
||||
};
|
||||
|
||||
const openEditProfile = (user: UserAccount) => {
|
||||
setEditProfileUser(user);
|
||||
@@ -537,8 +564,21 @@ export const UsersSection: React.FC<UsersSectionProps> = ({ currentUser, onRefre
|
||||
>
|
||||
编辑资料
|
||||
</button>
|
||||
{/* T20-F4-A:管理员重置密码端点未开通(F4-B 需产品选型),
|
||||
移除会失败的「重置密码」死按钮;引导走「停用 + 新建」流程。 */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleResetUserPassword(u)}
|
||||
style={{
|
||||
fontSize: '11px',
|
||||
color: 'var(--text-muted)',
|
||||
padding: '3px 6px',
|
||||
borderRadius: '4px',
|
||||
border: '1px solid var(--border)',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
title="重置为随机临时口令并强制下次登录改密"
|
||||
>
|
||||
重置密码
|
||||
</button>
|
||||
{!isSelf && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user