refactor: update default password configuration key and improve model field formatting

This commit is contained in:
wxg0103 2025-07-11 15:05:51 +08:00
parent c4df5cea5f
commit 414769f42d
3 changed files with 26 additions and 14 deletions

View File

@ -182,6 +182,9 @@ class UserManage(APIView):
operation_id=_("Get default password"), # type: ignore
tags=[_("User Management")], # type: ignore
responses=UserPasswordResponse.get_response())
@has_permissions(PermissionConstants.USER_CREATE, PermissionConstants.CHAT_USER_CREATE,
PermissionConstants.WORKSPACE_CHAT_USER_CREATE, RoleConstants.ADMIN,
RoleConstants.WORKSPACE_MANAGE)
def get(self, request: Request):
return result.success(data={'password': default_password})

View File

@ -73,6 +73,9 @@ const useUserStore = defineStore('user', {
}
},
is_admin() {
return this.userInfo?.role.includes('ADMIN')
},
showXpack() {
return this.edition != 'CE'
},
@ -91,7 +94,7 @@ const useUserStore = defineStore('user', {
isEE() {
return this.edition == 'EE' && this.license_is_valid
},
getEditionName() {
getEditionName() {
return this.edition
},
async profile(loading?: Ref<boolean>) {

View File

@ -1,8 +1,14 @@
import {RoleTypeEnum} from '@/enums/system'
import {t} from '@/locales'
import useStore from '@/stores'
const {user} = useStore()
export const roleTypeMap: Record<RoleTypeEnum, string> = {
...(user.is_admin()
? {
[RoleTypeEnum.ADMIN]: t('views.role.systemAdmin'),
[RoleTypeEnum.USER]: t('views.role.user'),
[RoleTypeEnum.WORKSPACE_MANAGE]: t('views.role.workspaceAdmin')
}
: {}),
[RoleTypeEnum.USER]: t('views.role.user'),
[RoleTypeEnum.WORKSPACE_MANAGE]: t('views.role.workspaceAdmin'),
};