Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/src/components/layout/Person.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const name = computed(() => userStore.getName)
const account = computed(() => userStore.getAccount)
const currentLanguage = computed(() => userStore.getLanguage)
const isAdmin = computed(() => userStore.isAdmin)
const isLocalUser = computed(() => !userStore.getOrigin)
const dialogVisible = ref(false)
const aboutRef = ref()
const languageList = computed(() => [
Expand Down Expand Up @@ -119,7 +120,7 @@ const logout = async () => {
</el-icon>
<div class="datasource-name">{{ $t('common.system_manage') }}</div>
</div>
<div class="popover-item" @click="openPwd">
<div v-if="isLocalUser" class="popover-item" @click="openPwd">
<el-icon size="16">
<icon_key_outlined></icon_key_outlined>
</el-icon>
Expand Down
24 changes: 22 additions & 2 deletions frontend/src/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface UserState {
exp: number
time: number
weight: number
origin: number
platformInfo: any | null
[key: string]: string | number | any | null
}
Expand All @@ -34,6 +35,7 @@ export const UserStore = defineStore('user', {
exp: 0,
time: 0,
weight: 0,
origin: 0,
platformInfo: null,
}
},
Expand Down Expand Up @@ -68,6 +70,9 @@ export const UserStore = defineStore('user', {
getWeight(): number {
return this.weight
},
getOrigin(): number {
return this.origin
},
isSpaceAdmin(): boolean {
return this.uid === '1' || !!this.weight
},
Expand Down Expand Up @@ -106,12 +111,22 @@ export const UserStore = defineStore('user', {
const res: any = await AuthApi.info()
const res_data = res || {}

const keys = ['uid', 'account', 'name', 'oid', 'language', 'exp', 'time', 'weight'] as const
const keys = [
'uid',
'account',
'name',
'oid',
'language',
'exp',
'time',
'weight',
'origin',
] as const

keys.forEach((key) => {
const dkey = key === 'uid' ? 'id' : key
const value = res_data[dkey]
if (key === 'exp' || key === 'time' || key === 'weight') {
if (key === 'exp' || key === 'time' || key === 'weight' || key === 'origin') {
this[key] = Number(value)
} else {
this[key] = String(value)
Expand Down Expand Up @@ -168,6 +183,10 @@ export const UserStore = defineStore('user', {
wsCache.set('user.weight', weight)
this.weight = weight
},
setOrigin(origin: number) {
wsCache.set('user.origin', origin)
this.origin = origin
},
setPlatformInfo(info: any | null) {
wsCache.set('user.platformInfo', info)
this.platformInfo = info
Expand All @@ -183,6 +202,7 @@ export const UserStore = defineStore('user', {
'exp',
'time',
'weight',
'origin',
'platformInfo',
]
keys.forEach((key) => wsCache.delete('user.' + key))
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/views/login/xpack/LdapLoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const submitForm = () => {
userStore.setToken(token)
userStore.setExp(res.exp)
userStore.setTime(Date.now())
userStore.setPlatformInfo({
flag: 'ldap',
data: null,
origin: 3,
})
router.push('/')
})
}
Expand Down