Skip to content

Commit

Permalink
fix(frontend): 权限问题修复 #3682
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx authored and iSecloud committed Apr 18, 2024
1 parent 4a13f46 commit 4ace358
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/components/auth-component/button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
background-color: transparent !important;
border-color: transparent !important;
* {
.bk-button-text {
color: #c4c6cc !important;
}
}
Expand Down
9 changes: 5 additions & 4 deletions dbm-ui/frontend/src/services/source/iam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import ApplyDataModel from '@services/model/iam/apply-data';

import http from '../http';
import http, { type IRequestPayload } from '../http';

const path = '/apis/iam';

Expand All @@ -39,10 +39,11 @@ export function checkAuthAllowed(params: IAMParams) {

export function simpleCheckAllowed(params: {
action_id: string;
resource_ids: Array<string | number>;
resource_ids?: Array<string | number>;
bk_biz_id?: number;
}) {
return http.post<boolean>(`${path}/simple_check_allowed/`, params);
is_raise_exception?: boolean;
}, payload = {} as IRequestPayload) {
return http.post<boolean>(`${path}/simple_check_allowed/`, params, payload);
}
/**
* 获取权限申请数据
Expand Down
6 changes: 2 additions & 4 deletions dbm-ui/frontend/src/stores/useUserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ export const useUserProfile = defineStore('UserProfile', {
*/
fetchProfile() {
return getProfile().then((result) => {
// this.globalManage = Boolean(result.global_manage);
this.globalManage = true;
// this.rerourceManage = Boolean(result.resource_manage);
this.rerourceManage = true;
this.globalManage = Boolean(result.global_manage);
this.rerourceManage = Boolean(result.resource_manage);
this.username = result.username;

this.profile = result.profile.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
<>
<auth-button
{...editBtnPermissionInfo }
resource={data.id}
class="mr-24"
text
theme="primary"
Expand All @@ -226,6 +227,7 @@
<span v-bk-tooltips={ tips }>
<auth-button
action-id="notify_group_delete"
resource={data.id}
permission={data.permission.notify_group_delete}
text
disabled={ btnDisabled }
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/views/mysql/permission-rule/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
getPermissionRules({
...getSearchSelectorParams(state.search),
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
account_type: 'mysql',
}, {
permission: 'catch'
})
Expand Down
21 changes: 18 additions & 3 deletions dbm-ui/frontend/src/views/password-manage/policy/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@
</BkFormItem>
</DbCard>
<BkFormItem class="password-policy-footer">
<AuthButton
action-id="password_policy_set"
<BkButton
class="mr-8"
:loading="isSubmitting"
theme="primary"
@click="handleSubmit()">
{{ t('保存') }}
</AuthButton>
</BkButton>
<BkButton
:disabled="isSubmitting"
@click="handleReset">
Expand All @@ -120,9 +119,12 @@

<script setup lang="ts">
import { Message } from 'bkui-vue';
import BkButton from 'bkui-vue/lib/button';
import { useI18n } from 'vue-i18n';
import { useRequest } from 'vue-request'

import { getPasswordPolicy, updatePasswordPolicy } from '@services/permission';
import {simpleCheckAllowed} from '@services/source/iam'

import { useInfo } from '@hooks';

Expand Down Expand Up @@ -156,6 +158,19 @@
const isSubmitting = ref(false);
const formData = reactive(initData());

useRequest(simpleCheckAllowed, {
defaultParams:[
{
action_id: 'password_policy_set',
resource_ids: [],
is_raise_exception: true
},
{
permission: 'page'
}
]
})

const fetchPasswordPolicy = () => {
isLoading.value = true;
getPasswordPolicy()
Expand Down
14 changes: 14 additions & 0 deletions dbm-ui/frontend/src/views/password-manage/randomization/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
import { useRequest } from 'vue-request';

import { getPasswordPolicy, modifyRandomCycle, queryRandomCycle } from '@services/permission';
import { simpleCheckAllowed } from '@services/source/iam'

const initData = () => ({
typeValue: 'day',
Expand Down Expand Up @@ -257,6 +258,19 @@
const unVisiblePassword = computed(() => '*'.repeat(formData.password.length));
const typeValue = computed(() => formData.timeData.typeValue);

useRequest(simpleCheckAllowed, {
defaultParams:[
{
action_id: 'password_policy_set',
resource_ids: [],
is_raise_exception: true
},
{
permission: 'page'
}
]
})

const { data: passwordPolicyData } = useRequest(getPasswordPolicy, {
defaultParams: [{}, { permission: 'page' }],
onSuccess(passwordPolicy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
ref="tableRef"
:columns="tableColumn"
:data-source="dataSource"
releate-url-query
@clear-search="handleClearSearch"
@select="handleSelect"
@select-all="handleSelectAll" />
Expand Down

0 comments on commit 4ace358

Please sign in to comment.