fix:Admin not allow change password

This commit is contained in:
马登山
2026-03-04 15:32:58 +08:00
parent c30bbf0a17
commit 9f35c1978a
3 changed files with 9 additions and 5 deletions
+2 -2
View File
@@ -76,12 +76,12 @@ export function ChangePassword({ visible, onVisibleChange }: ChangePasswordProps
accessKey: userInfo?.account_name ?? "",
secretKey: newSecretKey,
status: "enabled",
})
}, { suppress403Redirect: true })
message.success(t("Updated successfully"))
closeModal()
} catch (error) {
console.error(error)
message.error(t("Update failed"))
message.error((error as Error)?.message || t("Update failed"))
} finally {
setSubmitting(false)
}
+1 -1
View File
@@ -68,7 +68,7 @@ export function UserDropdown() {
<span>{(userInfo as { account_name?: string })?.account_name ?? (isAdmin ? "rustfsAdmin" : "")}</span>
</div>
</DropdownMenuItem>
{canChangePassword && (
{!isAdmin && (
<DropdownMenuItem onSelect={handleChangePassword}>
<RiLockPasswordLine className="h-4 w-4" />
<span>{t("Change Password")}</span>
+6 -2
View File
@@ -6,16 +6,20 @@ import { useApiOptional } from "@/contexts/api-context"
export function useUsers() {
const api = useApiOptional()
type UserRequestOptions = {
suppress403Redirect?: boolean
}
const listUsers = useCallback(async () => {
if (!api) return null
return api.get("/list-users")
}, [api])
const createUser = useCallback(
async (data: Record<string, unknown>) => {
async (data: Record<string, unknown>, options?: UserRequestOptions) => {
if (!api) return null
const { accessKey, ...rest } = data
return api.put(`/add-user?accessKey=${encodeURIComponent(accessKey as string)}`, rest)
return api.put(`/add-user?accessKey=${encodeURIComponent(accessKey as string)}`, rest, options)
},
[api],
)