Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: permission management and app access restrictions (#263) #271

Merged
merged 2 commits into from
Oct 14, 2024
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ VUE_APP_POLL_TIME=10000
VUE_APP_ORDER_FILTERS=["orderTypeId: SALES_ORDER", "facilityId:PRE_ORDER_PARKING OR facilityId:BACKORDER_PARKING", "orderStatusId: ORDER_APPROVED", "!orderItemStatusId: ITEM_CANCELLED" ]
VUE_APP_BASE_URL=
VUE_APP_ORDER_IN_BRKRNG_FILTERS=["orderTypeId: SALES_ORDER", "facilityId: _NA_", "orderStatusId: ORDER_APPROVED", "!orderItemStatusId: ITEM_CANCELLED" ]
VUE_APP_PERMISSION_ID=
VUE_APP_PERMISSION_ID="PREORDER_APP_VIEW"
VUE_APP_ALIAS=
VUE_APP_CTGRY_AND_BRKRNG_JOB=["JOB_REL_PREODR_CAT", "JOB_BKR_ORD", "JOB_RLS_ORD_DTE"]
VUE_APP_DEFAULT_ALIAS=
Expand Down
4 changes: 3 additions & 1 deletion src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ export default {
"APP_CATALOG_VIEW": "",
"APP_PRDT_DTLS_VIEW": "",
"APP_CTLG_PRDT_DTLS_VIEW": "",
"APP_INV_CNFG_UPDT": "COMMON_ADMIN"
"APP_INV_CNFG_UPDT": "COMMON_ADMIN",
"MERCHANDISING_ADMIN": "MERCHANDISING_ADMIN",
"PREORDER_APP_VIEW": "PREORDER_APP_VIEW"
} as any
12 changes: 8 additions & 4 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ const setUserPreference = async (payload: any): Promise<any> => {
});
}

const getEComStores = async (token: any, partyId: any): Promise<any> => {
const getEComStores = async (token: any, partyId: any, isAdminUser = false): Promise<any> => {
try {
const params = {
"inputFields": {
"storeName_op": "not-empty",
"partyId": partyId
"storeName_op": "not-empty"
},
"fieldList": ["productStoreId", "storeName"],
"entityName": "ProductStoreAndRole",
"distinct": "Y",
"noConditionFind": "Y"
"noConditionFind": "Y",
"filterByDate": 'Y'
} as any;

if(!isAdminUser) {
params.inputFields['partyId'] = partyId
}

const baseURL = store.getters['user/getBaseUrl'];
Expand Down
4 changes: 3 additions & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import RootState from '@/store/RootState'
import UserState from './UserState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'

Check warning on line 6 in src/store/modules/user/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'hasError' is defined but never used

Check warning on line 6 in src/store/modules/user/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'hasError' is defined but never used
import { translate } from '@/i18n'
import { Settings } from 'luxon'
import { updateInstanceUrl, updateToken, resetConfig, logout } from '@/adapter'
Expand Down Expand Up @@ -49,9 +49,11 @@
}
}

const isAdminUser = appPermissions.some((appPermission: any) => appPermission?.action === "MERCHANDISING_ADMIN");

// Getting user profile
const userProfile = await UserService.getUserProfile(token);
userProfile.stores = await UserService.getEComStores(token, userProfile.partyId);
userProfile.stores = await UserService.getEComStores(token, userProfile.partyId, isAdminUser);

// Getting user preferred store
let preferredStore = userProfile.stores[0];
Expand Down
Loading