Skip to content

Commit 025aa84

Browse files
committed
fix: Add controlled by isAdmin when changing password rustfs/rustfs#1020
1 parent d6de85a commit 025aa84

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎components/user-dropdown.vue‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</Button>
1212
</DropdownMenuTrigger>
1313
<DropdownMenuContent class="w-48" align="end" side="top">
14-
<DropdownMenuItem @select="handleChangePassword">
14+
<DropdownMenuItem v-if="!isAdmin" @select="handleChangePassword">
1515
<Icon name="ri:lock-password-line" class="h-4 w-4" />
1616
<span>{{ t('Change Password') }}</span>
1717
</DropdownMenuItem>
@@ -28,13 +28,14 @@
2828
import { Icon } from '#components'
2929
import { Button } from '@/components/ui/button'
3030
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'
31-
import { defineProps, ref, toRef, withDefaults } from 'vue'
31+
// import { defineProps, ref, toRef, withDefaults } from 'vue'
3232
import { useI18n } from 'vue-i18n'
3333
import AccessKeysChangePassword from '@/components/access-keys/change-password.vue'
3434
3535
const { t } = useI18n()
3636
const { logout } = useAuth()
3737
const router = useRouter()
38+
const { isAdminUser } = useUsers()
3839
3940
const props = withDefaults(
4041
defineProps<{
@@ -56,4 +57,10 @@ const handleLogout = async () => {
5657
await logout()
5758
router.push('/auth/login')
5859
}
60+
61+
const isAdmin = ref(false)
62+
onMounted(async () => {
63+
const adminInfo = await isAdminUser()
64+
isAdmin.value = adminInfo?.isAdmin || false
65+
})
5966
</script>

‎composables/useUsers.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ export const useUsers = () => {
7373
return await $api.post(`/user/${encodeURIComponent(name)}/service-account-credentials`, data)
7474
}
7575

76+
// isAdminUser
77+
const isAdminUser = async () => {
78+
return await $api.get(`/is-admin`)
79+
}
80+
7681
return {
7782
listUsers,
7883
createUser,
@@ -87,5 +92,6 @@ export const useUsers = () => {
8792
listAllUserServiceAccounts,
8893
createAUserServiceAccount,
8994
createServiceAccountCredentials,
95+
isAdminUser,
9096
}
9197
}

0 commit comments

Comments
 (0)