Skip to content

Commit

Permalink
Merge pull request #271 from amansinghbais/263-loginPermission
Browse files Browse the repository at this point in the history
Improved: permission management and app access restrictions (#263)
  • Loading branch information
ravilodhi authored Oct 14, 2024
2 parents 6b7d593 + 02677a8 commit 7f0fb25
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
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 @@ -49,9 +49,11 @@ const actions: ActionTree<UserState, RootState> = {
}
}

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

0 comments on commit 7f0fb25

Please sign in to comment.