mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
fix: change auth/V3user to auth/user (#824)
* fix: change auth/V3user to auth/user Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: extract to utils/auth.js Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import SteveModel from '@shell/plugins/steve/steve-class';
|
||||
import { escapeHtml } from '@shell/utils/string';
|
||||
import { HCI } from '../types';
|
||||
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
|
||||
import { getHarvesterUserName } from '../utils/auth';
|
||||
|
||||
const STATUS_DISPLAY = {
|
||||
enabled: {
|
||||
@@ -96,15 +97,8 @@ export default class PCIDevice extends SteveModel {
|
||||
if (!this.passthroughClaim) {
|
||||
return false;
|
||||
}
|
||||
const isSingleProduct = this.$rootGetters['isSingleProduct'];
|
||||
let userName = 'admin';
|
||||
|
||||
// if this is imported Harvester, there may be users other than admin
|
||||
if (!isSingleProduct) {
|
||||
const user = this.$rootGetters['auth/v3User'];
|
||||
|
||||
userName = user?.username || user?.id;
|
||||
}
|
||||
const userName = getHarvesterUserName(this.$rootGetters);
|
||||
|
||||
return this.claimedBy === userName;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import SteveModel from '@shell/plugins/steve/steve-class';
|
||||
import { escapeHtml } from '@shell/utils/string';
|
||||
import { HCI } from '../types';
|
||||
import { getHarvesterUserName } from '../utils/auth';
|
||||
|
||||
const STATUS_DISPLAY = {
|
||||
enabled: {
|
||||
@@ -87,15 +88,8 @@ export default class USBDevice extends SteveModel {
|
||||
if (!this.passthroughClaim) {
|
||||
return false;
|
||||
}
|
||||
const isSingleProduct = this.$rootGetters['isSingleProduct'];
|
||||
let userName = 'admin';
|
||||
|
||||
// if this is imported Harvester, there may be users other than admin
|
||||
if (!isSingleProduct) {
|
||||
const user = this.$rootGetters['auth/v3User'];
|
||||
|
||||
userName = user?.username || user?.id;
|
||||
}
|
||||
const userName = getHarvesterUserName(this.$rootGetters);
|
||||
|
||||
return this.claimedBy === userName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user