Skip to content

Commit a6744dd

Browse files
perf(X-Pack): Hide Password Change for Third-Party Users
1 parent 1c104e9 commit a6744dd

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

frontend/src/components/layout/Person.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const name = computed(() => userStore.getName)
3131
const account = computed(() => userStore.getAccount)
3232
const currentLanguage = computed(() => userStore.getLanguage)
3333
const isAdmin = computed(() => userStore.isAdmin)
34+
const isLocalUser = computed(() => !userStore.getOrigin)
3435
const dialogVisible = ref(false)
3536
const aboutRef = ref()
3637
const languageList = computed(() => [
@@ -119,7 +120,7 @@ const logout = async () => {
119120
</el-icon>
120121
<div class="datasource-name">{{ $t('common.system_manage') }}</div>
121122
</div>
122-
<div class="popover-item" @click="openPwd">
123+
<div v-if="isLocalUser" class="popover-item" @click="openPwd">
123124
<el-icon size="16">
124125
<icon_key_outlined></icon_key_outlined>
125126
</el-icon>

frontend/src/stores/user.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface UserState {
1818
exp: number
1919
time: number
2020
weight: number
21+
origin: number
2122
platformInfo: any | null
2223
[key: string]: string | number | any | null
2324
}
@@ -34,6 +35,7 @@ export const UserStore = defineStore('user', {
3435
exp: 0,
3536
time: 0,
3637
weight: 0,
38+
origin: 0,
3739
platformInfo: null,
3840
}
3941
},
@@ -68,6 +70,9 @@ export const UserStore = defineStore('user', {
6870
getWeight(): number {
6971
return this.weight
7072
},
73+
getOrigin(): number {
74+
return this.origin
75+
},
7176
isSpaceAdmin(): boolean {
7277
return this.uid === '1' || !!this.weight
7378
},
@@ -106,12 +111,22 @@ export const UserStore = defineStore('user', {
106111
const res: any = await AuthApi.info()
107112
const res_data = res || {}
108113

109-
const keys = ['uid', 'account', 'name', 'oid', 'language', 'exp', 'time', 'weight'] as const
114+
const keys = [
115+
'uid',
116+
'account',
117+
'name',
118+
'oid',
119+
'language',
120+
'exp',
121+
'time',
122+
'weight',
123+
'origin',
124+
] as const
110125

111126
keys.forEach((key) => {
112127
const dkey = key === 'uid' ? 'id' : key
113128
const value = res_data[dkey]
114-
if (key === 'exp' || key === 'time' || key === 'weight') {
129+
if (key === 'exp' || key === 'time' || key === 'weight' || key === 'origin') {
115130
this[key] = Number(value)
116131
} else {
117132
this[key] = String(value)
@@ -168,6 +183,10 @@ export const UserStore = defineStore('user', {
168183
wsCache.set('user.weight', weight)
169184
this.weight = weight
170185
},
186+
setOrigin(origin: number) {
187+
wsCache.set('user.origin', origin)
188+
this.origin = origin
189+
},
171190
setPlatformInfo(info: any | null) {
172191
wsCache.set('user.platformInfo', info)
173192
this.platformInfo = info
@@ -183,6 +202,7 @@ export const UserStore = defineStore('user', {
183202
'exp',
184203
'time',
185204
'weight',
205+
'origin',
186206
'platformInfo',
187207
]
188208
keys.forEach((key) => wsCache.delete('user.' + key))

frontend/src/views/login/xpack/LdapLoginForm.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ const submitForm = () => {
5959
userStore.setToken(token)
6060
userStore.setExp(res.exp)
6161
userStore.setTime(Date.now())
62+
userStore.setPlatformInfo({
63+
flag: 'ldap',
64+
data: null,
65+
origin: 3,
66+
})
6267
router.push('/')
6368
})
6469
}

0 commit comments

Comments
 (0)