From 8803b795247cdecdda29c228b6f78d39e8c1992d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 15:42:30 +0800 Subject: [PATCH] fix: change auth/V3user to auth/user (#824) (#825) * fix: change auth/V3user to auth/user * refactor: extract to utils/auth.js --------- (cherry picked from commit 6fdd1e3954ca730a082c72e558fd79a54b65084f) Signed-off-by: Andy Lee Co-authored-by: Andy Lee --- pkg/harvester/dialog/EnablePciPassthrough.vue | 12 ++----- pkg/harvester/dialog/EnableUSBPassthrough.vue | 12 ++----- .../HarvesterBackupTargetValidation.vue | 3 +- .../devices.harvesterhci.io.pcidevice.js | 10 ++---- .../devices.harvesterhci.io.usbdevice.js | 10 ++---- pkg/harvester/utils/auth.js | 31 +++++++++++++++++++ 6 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 pkg/harvester/utils/auth.js diff --git a/pkg/harvester/dialog/EnablePciPassthrough.vue b/pkg/harvester/dialog/EnablePciPassthrough.vue index 1d5aaaa4..733099a7 100644 --- a/pkg/harvester/dialog/EnablePciPassthrough.vue +++ b/pkg/harvester/dialog/EnablePciPassthrough.vue @@ -4,6 +4,7 @@ import { Card } from '@components/Card'; import AsyncButton from '@shell/components/AsyncButton'; import { escapeHtml } from '@shell/utils/string'; import { HCI } from '../types'; +import { getHarvesterUserName } from '../utils/auth'; export default { name: 'HarvesterEnablePciPassthrough', @@ -34,16 +35,7 @@ export default { }, async save(buttonCb) { - // isSingleProduct == this is a standalone Harvester cluster - const isSingleProduct = this.$store.getters['isSingleProduct']; - let userName = 'admin'; - - // if this is imported Harvester, there may be users other than 'admin - if (!isSingleProduct) { - const user = this.$store.getters['auth/v3User']; - - userName = user?.username || user?.id; - } + const userName = getHarvesterUserName(this.$store.getters); for (let i = 0; i < this.resources.length; i++) { const actionResource = this.resources[i]; diff --git a/pkg/harvester/dialog/EnableUSBPassthrough.vue b/pkg/harvester/dialog/EnableUSBPassthrough.vue index 9ad7ae30..fd3bf0ea 100644 --- a/pkg/harvester/dialog/EnableUSBPassthrough.vue +++ b/pkg/harvester/dialog/EnableUSBPassthrough.vue @@ -4,6 +4,7 @@ import { Card } from '@components/Card'; import AsyncButton from '@shell/components/AsyncButton'; import { escapeHtml } from '@shell/utils/string'; import { HCI } from '../types'; +import { getHarvesterUserName } from '../utils/auth'; export default { name: 'HarvesterEnableUSBPassthrough', @@ -34,16 +35,7 @@ export default { }, async save(buttonCb) { - // isSingleProduct == this is a standalone Harvester cluster - const isSingleProduct = this.$store.getters['isSingleProduct']; - let userName = 'admin'; - - // if this is imported Harvester, there may be users other than 'admin - if (!isSingleProduct) { - const user = this.$store.getters['auth/v3User']; - - userName = user?.username || user?.id; - } + const userName = getHarvesterUserName(this.$store.getters); for (let i = 0; i < this.resources.length; i++) { const actionResource = this.resources[i]; diff --git a/pkg/harvester/formatters/HarvesterBackupTargetValidation.vue b/pkg/harvester/formatters/HarvesterBackupTargetValidation.vue index 2c4f53dc..25679c6c 100644 --- a/pkg/harvester/formatters/HarvesterBackupTargetValidation.vue +++ b/pkg/harvester/formatters/HarvesterBackupTargetValidation.vue @@ -1,6 +1,7 @@