mirror of
https://github.com/rustfs/console.git
synced 2026-08-30 17:14:47 +08:00
fix:Admin not allow change password
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
@@ -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],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user