@simitgroup/simpleapp-generator 2.0.0-y-alpha → 2.0.1-b-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReleaseNote.md +16 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -2
- package/templates/nest/src/simple-app/_core/features/auth/role-guard/roles.enum.ts.eta +4 -1
- package/templates/nest/src/simple-app/_core/features/cron/base/cron.base.ts.eta +11 -11
- package/templates/nest/src/simple-app/_core/features/maintenance/maintenance.controller.ts.eta +26 -7
- package/templates/nest/src/simple-app/_core/features/maintenance/maintenance.service.ts.eta +25 -12
- package/templates/nest/src/simple-app/_core/features/maintenance/schemas/environment.ts.eta +37 -20
- package/templates/nest/src/simple-app/_core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +3 -3
- package/templates/nest/src/simple-app/_core/features/policy/policy.service.ts.eta +5 -8
- package/templates/nest/src/simple-app/_core/features/queue/queue-base/queue-base.consumer.ts.eta +5 -5
- package/templates/nest/src/simple-app/_core/features/queue/queue-user-context/queue-user-context.service.ts.eta +4 -4
- package/templates/nest/src/simple-app/_core/features/user-context/robot-user.service.ts.eta +17 -11
- package/templates/nest/src/simple-app/_core/features/user-context/user-context.module.ts.eta +2 -1
- package/templates/nest/src/simple-app/_core/features/user-context/user.context.ts.eta +28 -5
- package/templates/nest/src/simple-app/_core/framework/base/simple-app.service.ts.eta +56 -56
- package/templates/nest/src/simple-app/_core/framework/simple-app.middleware.ts.eta +1 -1
- package/templates/nuxt/composables/getMenus.generate.ts.eta +86 -0
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +19 -23
- package/templates/nuxt/middleware/30.acl.global.ts._eta +139 -0
- package/templates/nuxt/pages/[xorg]/profile.vue.eta +5 -2
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +54 -64
- package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppPageIframe.vue.eta +1 -0
- package/templates/nest/src/simple-app/_core/features/mini-app/developer-portal/dto/developer-portal-create-app.dto.ts.eta +0 -22
- package/templates/nest/src/simple-app/_core/features/mini-app/developer-portal/dto/developer-portal-publish-app.dto.ts.eta +0 -0
- package/templates/nuxt/middleware/30.acl.global.ts.eta +0 -48
|
@@ -1316,63 +1316,63 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
1316
1316
|
},
|
|
1317
1317
|
];
|
|
1318
1318
|
|
|
1319
|
-
// Relation lookups
|
|
1320
|
-
Object.entries(option.relations).forEach(([relationName, relationOption]) => {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
});
|
|
1360
|
-
|
|
1361
|
-
// Root sort
|
|
1362
|
-
if (option.root?.sort) {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
}
|
|
1319
|
+
// // Relation lookups
|
|
1320
|
+
// Object.entries(option.relations).forEach(([relationName, relationOption]) => {
|
|
1321
|
+
// // Prevent mini api user lookup sensitive data
|
|
1322
|
+
// if (!allowedRelations.includes(relationName)) {
|
|
1323
|
+
// throw new BadRequestException(`Not allowed to lookup ${relationName}`);
|
|
1324
|
+
// }
|
|
1325
|
+
|
|
1326
|
+
// const subPipeline: PipelineStage.Lookup['$lookup']['pipeline'] = [];
|
|
1327
|
+
|
|
1328
|
+
// subPipeline.push({
|
|
1329
|
+
// $match: {
|
|
1330
|
+
// $expr: { $eq: [`$${relationOption.foreignField}`, '$$localValue'] },
|
|
1331
|
+
// },
|
|
1332
|
+
// ...relationOption.filter,
|
|
1333
|
+
// });
|
|
1334
|
+
|
|
1335
|
+
// // Relation sort
|
|
1336
|
+
// if (relationOption.sort) {
|
|
1337
|
+
// subPipeline.push({
|
|
1338
|
+
// $sort: relationOption.sort,
|
|
1339
|
+
// });
|
|
1340
|
+
// }
|
|
1341
|
+
|
|
1342
|
+
// // Relation projection
|
|
1343
|
+
// if (relationOption.projection) {
|
|
1344
|
+
// subPipeline.push({
|
|
1345
|
+
// $project: {
|
|
1346
|
+
// ...(relationOption.projection ?? {}),
|
|
1347
|
+
// },
|
|
1348
|
+
// });
|
|
1349
|
+
// }
|
|
1350
|
+
|
|
1351
|
+
// pipeline.push({
|
|
1352
|
+
// $lookup: {
|
|
1353
|
+
// from: relationName.toLowerCase(),
|
|
1354
|
+
// as: `_${relationName}`,
|
|
1355
|
+
// let: { localValue: `$${relationOption.localField}` },
|
|
1356
|
+
// pipeline: subPipeline,
|
|
1357
|
+
// },
|
|
1358
|
+
// });
|
|
1359
|
+
// });
|
|
1360
|
+
|
|
1361
|
+
// // Root sort
|
|
1362
|
+
// if (option.root?.sort) {
|
|
1363
|
+
// pipeline.push({
|
|
1364
|
+
// $sort: option.root.sort,
|
|
1365
|
+
// });
|
|
1366
|
+
// }
|
|
1367
1367
|
|
|
1368
|
-
// Root Projection
|
|
1369
|
-
if (option.root.projection) {
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
}
|
|
1368
|
+
// // Root Projection
|
|
1369
|
+
// if (option.root.projection) {
|
|
1370
|
+
// pipeline.push({
|
|
1371
|
+
// $project: {
|
|
1372
|
+
// ...(option.root?.projection ?? {}),
|
|
1373
|
+
// },
|
|
1374
|
+
// });
|
|
1375
|
+
// }
|
|
1376
1376
|
|
|
1377
1377
|
return await this.aggregate(appUser, pipeline);
|
|
1378
1378
|
}
|
|
@@ -66,7 +66,7 @@ export class SimpleAppMiddleware implements NestMiddleware {
|
|
|
66
66
|
tokenStr = tokenStr.replace('Bearer ', '');
|
|
67
67
|
const xOrg = req.get('x-org') ?? this.defaultXOrg;
|
|
68
68
|
|
|
69
|
-
const user = new UserContext(this.userModel, this.permModel, this.miniAppInstallationModel);
|
|
69
|
+
const user = new UserContext(this.userModel, this.permModel, this.miniAppInstallationModel,envs[0]);
|
|
70
70
|
|
|
71
71
|
if (req.baseUrl == '/graphql') {
|
|
72
72
|
if (tokenStr) {
|
|
@@ -67,4 +67,90 @@ export const getMenustFromPageMeta =() =>{
|
|
|
67
67
|
|
|
68
68
|
return allmenus.sort((one:string, two:string) => (one > two ? -1 : 1))
|
|
69
69
|
|
|
70
|
+
}
|
|
71
|
+
export const hasAccessByPageMeta = (pageName: string): boolean => {
|
|
72
|
+
const userGroups = getUserStore().groups || []
|
|
73
|
+
const userRoles = getUserStore().roles || []
|
|
74
|
+
|
|
75
|
+
if (
|
|
76
|
+
userRoles.includes('superadmin') ||
|
|
77
|
+
userRoles.includes('tenantowner') ||
|
|
78
|
+
userRoles.includes('superuser')
|
|
79
|
+
) {
|
|
80
|
+
return true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const routes = useRouter().getRoutes()
|
|
84
|
+
const route = routes.find((r) => {
|
|
85
|
+
const menuPath = r.meta?.menuPath as string | undefined
|
|
86
|
+
return menuPath && menuPath.endsWith(`/${pageName}`)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
if (!route || !route.meta) {
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const requiredGroups = route.meta.requiredGroups as string[] | undefined
|
|
94
|
+
|
|
95
|
+
if (!requiredGroups || requiredGroups.length === 0) {
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return requiredGroups.some((group) => userGroups.includes(group))
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const getMenusWithPageMetaAccess = (xorg: string): MenuData[] => {
|
|
103
|
+
const routes = useRouter().getRoutes()
|
|
104
|
+
const allowedMenus: MenuData[] = []
|
|
105
|
+
const { getDescription, getIcon, getIconColor } = useSettingsMenu()
|
|
106
|
+
|
|
107
|
+
const menuRoutes = routes.filter((route) => route.meta && route.meta.menuPath)
|
|
108
|
+
|
|
109
|
+
for (const route of menuRoutes) {
|
|
110
|
+
const menuPath = route.meta.menuPath as string
|
|
111
|
+
const requiredGroups = route.meta.requiredGroups as string[] | undefined
|
|
112
|
+
|
|
113
|
+
const pathParts = menuPath.split('/')
|
|
114
|
+
const pageName = pathParts[pathParts.length - 1]
|
|
115
|
+
|
|
116
|
+
if (hasAccessByPageMeta(pageName)) {
|
|
117
|
+
const icon = getIcon(pageName)
|
|
118
|
+
const iconClass = getIconColor(pageName)
|
|
119
|
+
|
|
120
|
+
const menuItem: MenuData = {
|
|
121
|
+
label: t(pageName),
|
|
122
|
+
url: `/${xorg}/${pageName}`,
|
|
123
|
+
isolationType: 'none',
|
|
124
|
+
icon: typeof icon === 'string' ? icon : '',
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
allowedMenus.push(menuItem)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return allowedMenus
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const getMenuMetadata = (pageName: string) => {
|
|
135
|
+
const routes = useRouter().getRoutes()
|
|
136
|
+
const route = routes.find((r) => {
|
|
137
|
+
const menuPath = r.meta?.menuPath as string | undefined
|
|
138
|
+
return menuPath && menuPath.endsWith(`/${pageName}`)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
if (route?.meta) {
|
|
142
|
+
return {
|
|
143
|
+
description: route.meta.description ? t(route.meta.description as string) : t(pageName),
|
|
144
|
+
icon: route.meta.icon || '',
|
|
145
|
+
colorClass: route.meta.colorClass || '',
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const { getDescription, getIcon, getIconColor } = useSettingsMenu()
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
description: t(getDescription(pageName)),
|
|
153
|
+
icon: getIcon(pageName),
|
|
154
|
+
colorClass: getIconColor(pageName),
|
|
155
|
+
}
|
|
70
156
|
}
|
|
@@ -12,6 +12,10 @@ export const getUserStore = () => {
|
|
|
12
12
|
const { $userstore } = useNuxtApp();
|
|
13
13
|
return $userstore;
|
|
14
14
|
};
|
|
15
|
+
export const reloadUserStoreFromMiddleware = async (xorg:string) => {
|
|
16
|
+
const { $userstore } = useNuxtApp();
|
|
17
|
+
await $userstore.loadRemoteUserFromXorg(xorg)
|
|
18
|
+
};
|
|
15
19
|
export const reloadUserStore = async () => {
|
|
16
20
|
const { $userstore } = useNuxtApp();
|
|
17
21
|
await $userstore.loadRemoteUserInfo();
|
|
@@ -25,17 +29,15 @@ export const isGuideComplete = (guidename: string): boolean => {
|
|
|
25
29
|
} else return false;
|
|
26
30
|
};
|
|
27
31
|
export const setGuideComplete = async (guidename: string) => {
|
|
28
|
-
const userstore = useNuxtApp().$userstore;
|
|
29
|
-
await getProfileApi().runTourComplete(guidename);
|
|
30
|
-
if (getUserProfile() !== undefined) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export const getCurrentXorg = () => {
|
|
37
|
-
return useRoute().params.xorg ? String(useRoute().params.xorg) : undefined;
|
|
32
|
+
// const userstore = useNuxtApp().$userstore;
|
|
33
|
+
// await getProfileApi().runTourComplete(guidename);
|
|
34
|
+
// if (getUserProfile() !== undefined) {
|
|
35
|
+
// if (!Array.isArray(getUserProfile()?.moreProps.completedTours))
|
|
36
|
+
// userstore.moreProps.completedTours = [guidename];
|
|
37
|
+
// else userstore.moreProps.completedTours.push(guidename);
|
|
38
|
+
// }
|
|
38
39
|
};
|
|
40
|
+
export const getCurrentXorg = () => getUserStore().xOrg ?? ''
|
|
39
41
|
export const getPageBaseUrl = (resourcename: string) => {
|
|
40
42
|
return `/${getCurrentXorg()}/${resourcename}`;
|
|
41
43
|
};
|
|
@@ -60,19 +62,13 @@ export const getProfileEmail = () => getUserProfile()?.email;
|
|
|
60
62
|
export const getProfileUid = () => getUserProfile()?.uid;
|
|
61
63
|
export const getProfileFullName = () => getUserProfile()?.fullName;
|
|
62
64
|
|
|
63
|
-
export const refreshOrgLogo = async () => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
export const getOrgLogo = () => orgLogo;
|
|
68
|
-
export const setOrgLogo = (str: string) => (orgLogo = str);
|
|
69
|
-
export const getCurrentBranch = () =>
|
|
70
|
-
const branchId = getUserStore().branchId;
|
|
71
|
-
const branchinfo = getUserStore().branches.find(
|
|
72
|
-
(item) => item.branch.branchId == branchId,
|
|
73
|
-
);
|
|
74
|
-
return branchinfo;
|
|
75
|
-
};
|
|
65
|
+
// export const refreshOrgLogo = async () => {
|
|
66
|
+
// const logodata = await useNuxtApp().$OrganizationDoc().getApi().runGetlogo();
|
|
67
|
+
// orgLogo = logodata.data;
|
|
68
|
+
// };
|
|
69
|
+
// export const getOrgLogo = () => orgLogo;
|
|
70
|
+
// export const setOrgLogo = (str: string) => (orgLogo = str);
|
|
71
|
+
export const getCurrentBranch = () => getUserProfile().branchInfo;
|
|
76
72
|
|
|
77
73
|
export const getMySimpleAppUserPicker = () => {
|
|
78
74
|
return {
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { RouteLocationNormalizedGeneric } from 'vue-router';
|
|
2
|
+
import { getUserProfile } from './../composables/getUserStore.generate';
|
|
3
|
+
|
|
4
|
+
export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
5
|
+
console.log(to.path)
|
|
6
|
+
const userProfile = getUserProfile()
|
|
7
|
+
const xorg = <string>to.params['xorg'] ?? 'MC0wLTA'
|
|
8
|
+
useNuxtApp().$userstore.xOrg=xorg
|
|
9
|
+
if(!userProfile?._id){
|
|
10
|
+
// console.error("middleware detect no user id, reload under xorg",xorg)
|
|
11
|
+
await reloadUserStoreFromMiddleware(xorg)
|
|
12
|
+
// console.log("after reload",userProfile)
|
|
13
|
+
}else if(userProfile.branchId===0 && xorg !='MC0wLTA'){
|
|
14
|
+
// console.error("middleware detect wrong xorg reload profile for",xorg)
|
|
15
|
+
await reloadUserStoreFromMiddleware(xorg)
|
|
16
|
+
// console.log("after reload",userProfile)
|
|
17
|
+
}else{
|
|
18
|
+
// console.log("use exists, use back the user store")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const currentgroup = useCookie('currentGroup').value
|
|
24
|
+
if(currentgroup && userProfile.groups.includes(currentgroup)){
|
|
25
|
+
//use back ground
|
|
26
|
+
}else if(userProfile.groups.length>0){
|
|
27
|
+
goTo('pickgroup')
|
|
28
|
+
}
|
|
29
|
+
// if (!currentgroup)goTo('pickgroup')
|
|
30
|
+
|
|
31
|
+
// console.log("userProfile1",userProfile)
|
|
32
|
+
// console.log(xorg)
|
|
33
|
+
|
|
34
|
+
const { status } = useAuth();
|
|
35
|
+
const metas = Object.keys(to.meta)
|
|
36
|
+
|
|
37
|
+
if(status.value=='unauthenticated'){
|
|
38
|
+
if(to.meta.auth===false){
|
|
39
|
+
return true
|
|
40
|
+
}else{
|
|
41
|
+
navigateTo('/login')
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const license = useLicense().getLicense()
|
|
46
|
+
console.log("metas check",metas)
|
|
47
|
+
if(metas.length == 0){
|
|
48
|
+
throw createError({
|
|
49
|
+
statusCode: 404,
|
|
50
|
+
statusMessage: 'pageDoesNotExists',
|
|
51
|
+
message: 'pageDoesNotExistsMsg',
|
|
52
|
+
fatal: true,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if(to.meta['licenseWeight'] === undefined){
|
|
56
|
+
throw createError({
|
|
57
|
+
statusCode: 403,
|
|
58
|
+
statusMessage: 'undefinePageMetaLicenseWeight',
|
|
59
|
+
message: 'undefinePageMetaLicenseWeightMsg',
|
|
60
|
+
fatal: true,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if(to.meta['requiredGroups']===undefined || !Array.isArray(to.meta['requiredGroups'])){
|
|
65
|
+
throw createError({
|
|
66
|
+
statusCode: 403,
|
|
67
|
+
statusMessage: 'undefinePageMetaRequiredGroups',
|
|
68
|
+
message: 'undefinePageMetaRequiredGroupsMsg',
|
|
69
|
+
fatal: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if(to.meta['licenseWeight'] && <number>to.meta['licenseWeight']> license.licenseWeight){
|
|
74
|
+
throw createError({
|
|
75
|
+
statusCode: 403,
|
|
76
|
+
statusMessage: 'upgradeSoftwareLicenseRequired',
|
|
77
|
+
message: 'upgradeSoftwareLicenseRequiredMsg',
|
|
78
|
+
fatal: true,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if(to.meta['requiredGroups']){
|
|
84
|
+
|
|
85
|
+
const requiredGroups:string[] = to.meta['requiredGroups']
|
|
86
|
+
const userGroups = userProfile.groups
|
|
87
|
+
let allowAccess = false
|
|
88
|
+
if(['','/'].includes(to.path)) allowAccess= true
|
|
89
|
+
|
|
90
|
+
for(const g of requiredGroups){
|
|
91
|
+
|
|
92
|
+
if(userGroups.includes(g)){
|
|
93
|
+
allowAccess = true
|
|
94
|
+
}
|
|
95
|
+
if(userProfile.roles.includes(g)){
|
|
96
|
+
allowAccess = true
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
if(!allowAccess){
|
|
101
|
+
throw createError({
|
|
102
|
+
statusCode: 403,
|
|
103
|
+
statusMessage: 'insufficientPriviledge',
|
|
104
|
+
message: 'insufficientPriviledgeMsg',
|
|
105
|
+
fatal: true,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
console.log("middleware check isexpired",useLicense().isExpired())
|
|
110
|
+
if(!useLicense().isExpired()) {
|
|
111
|
+
return true
|
|
112
|
+
}else if(allowAccessExpired(to)){
|
|
113
|
+
return true
|
|
114
|
+
}else{
|
|
115
|
+
throw createError({
|
|
116
|
+
statusCode: 402,
|
|
117
|
+
statusMessage: 'systemExpired',
|
|
118
|
+
message:'systemExpiredMsg',
|
|
119
|
+
fatal: true,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
const allowAccessExpired = (to:RouteLocationNormalizedGeneric)=>{
|
|
126
|
+
const userProfile = getUserProfile()
|
|
127
|
+
let allowPass = false
|
|
128
|
+
const isSuperAdmin = userProfile.groups.includes('superadmin')
|
|
129
|
+
if(isSuperAdmin){
|
|
130
|
+
allowPass=true
|
|
131
|
+
}
|
|
132
|
+
const allowedPath = ['/billing','/pickgroup']
|
|
133
|
+
for(const p of allowedPath){
|
|
134
|
+
console.log("to.path.includes",to.path,p)
|
|
135
|
+
if(to.path.includes(p))allowPass = true
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return allowPass
|
|
139
|
+
}
|
|
@@ -53,12 +53,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
53
53
|
}),
|
|
54
54
|
|
|
55
55
|
actions: {
|
|
56
|
-
async
|
|
57
|
-
// console.log('loadRemoteUserInfo')
|
|
58
|
-
|
|
56
|
+
async loadRemoteUserFromXorg(xorg:string) {
|
|
59
57
|
const { $axios, $miniAppStore, $customFieldStore } = useNuxtApp();
|
|
60
|
-
|
|
61
|
-
let xorg = this.getCurrentXorg();
|
|
58
|
+
|
|
62
59
|
let apiurl = "";
|
|
63
60
|
if (!xorg) {
|
|
64
61
|
apiurl = `${useRuntimeConfig().public.appUrl}/api`;
|
|
@@ -76,7 +73,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
76
73
|
return;
|
|
77
74
|
}
|
|
78
75
|
const res = tmp.data
|
|
79
|
-
|
|
76
|
+
this.xOrg= xorg
|
|
80
77
|
this._id = res._id;
|
|
81
78
|
this.uName = res.uName;
|
|
82
79
|
this.sessionId = res.sessionId;
|
|
@@ -103,7 +100,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
103
100
|
this.groups = res.groups;
|
|
104
101
|
this.roles = res.roles;
|
|
105
102
|
this.time = res.time;
|
|
106
|
-
|
|
103
|
+
|
|
107
104
|
this.invites = res.invites;
|
|
108
105
|
this.moreProps = res.moreProps;
|
|
109
106
|
// this.package = res.moreProps.package;
|
|
@@ -122,15 +119,14 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
122
119
|
return Promise.reject(err);
|
|
123
120
|
});
|
|
124
121
|
},
|
|
122
|
+
async loadRemoteUserInfo() {
|
|
123
|
+
const route = useRoute();
|
|
124
|
+
let xorg = this.getCurrentXorg();
|
|
125
|
+
await this.loadRemoteUserFromXorg(xorg)
|
|
126
|
+
|
|
127
|
+
},
|
|
125
128
|
getCurrentXorg() {
|
|
126
|
-
|
|
127
|
-
let result = ''
|
|
128
|
-
if(typeof xorg == 'string'){
|
|
129
|
-
result = xorg
|
|
130
|
-
}else{
|
|
131
|
-
result =''
|
|
132
|
-
}
|
|
133
|
-
return result
|
|
129
|
+
return this.xOrg
|
|
134
130
|
},
|
|
135
131
|
async pingSession(): Promise<string> {
|
|
136
132
|
let xorg = this.getCurrentXorg();
|
|
@@ -184,59 +180,57 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
184
180
|
this.roles.includes(permission),
|
|
185
181
|
);
|
|
186
182
|
},
|
|
187
|
-
canPerform(resourcename: string, action: string): boolean {
|
|
183
|
+
canPerform(resourcename: string, action: string): boolean {
|
|
184
|
+
const normalizedResource = resourcename.toLowerCase();
|
|
185
|
+
|
|
188
186
|
if (
|
|
189
187
|
this.roles.includes("superadmin") ||
|
|
190
188
|
this.roles.includes("tenantowner") ||
|
|
191
189
|
this.roles.includes("superuser")
|
|
192
190
|
) {
|
|
193
191
|
return true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
} else if (resourcename == "Upgradelevel") {
|
|
211
|
-
if (
|
|
212
|
-
this.roles.includes("admin") ||
|
|
213
|
-
this.roles.includes("manager") ||
|
|
214
|
-
this.roles.includes("executive")
|
|
215
|
-
) {
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
} else if (resourcename == "Appintegration") {
|
|
219
|
-
if (this.roles.includes("admin") || this.roles.includes("manager")) {
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
} else if (resourcename == "Postingtosimbiz") {
|
|
223
|
-
if (this.roles.includes("admin")) {
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const specialCases: Record<string, string[]> = {
|
|
195
|
+
// paymentverify: ["admin", "manager"],
|
|
196
|
+
// reminder: ["admin", "manager"],
|
|
197
|
+
// generateinvoice: ["admin", "manager", "executive"],
|
|
198
|
+
// upgradelevel: ["admin", "manager", "executive"],
|
|
199
|
+
appintegration: ["admin", "manager"],
|
|
200
|
+
miniapp: ["admin", "manager"],
|
|
201
|
+
studentdescription: ["admin", "manager", "executive"],
|
|
202
|
+
miniappinstallation: ["admin", "manager"],
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
if (specialCases[normalizedResource]) {
|
|
206
|
+
const requiredGroups = specialCases[normalizedResource];
|
|
207
|
+
if (requiredGroups.some((group) => this.roles.includes(group))) {
|
|
224
208
|
return true;
|
|
225
209
|
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
const routes = useRouter().getRoutes();
|
|
214
|
+
const route = routes.find((r) => {
|
|
215
|
+
const menuPath = r.meta?.menuPath as string | undefined;
|
|
216
|
+
return menuPath && menuPath.endsWith(`/${normalizedResource}`);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
if (route?.meta?.requiredGroups) {
|
|
220
|
+
const requiredGroups = route.meta.requiredGroups as string[];
|
|
221
|
+
const userGroups = this.groups || [];
|
|
222
|
+
|
|
223
|
+
if (requiredGroups.some((group) => userGroups.includes(group))) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
233
226
|
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// console.log("verify",checkstr)
|
|
237
|
-
return this.roles.includes(checkstr);
|
|
227
|
+
} catch (e) {
|
|
228
|
+
console.error(e)
|
|
238
229
|
}
|
|
239
|
-
|
|
230
|
+
|
|
231
|
+
const checkstr = `${normalizedResource}:${action}`;
|
|
232
|
+
const checkstrOriginal = `${resourcename}:${action}`;
|
|
233
|
+
return this.roles.includes(checkstr) || this.roles.includes(checkstrOriginal);
|
|
240
234
|
},
|
|
241
235
|
haveAccess(resourcename: string) {
|
|
242
236
|
//super admin always full access right
|
|
@@ -248,11 +242,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
248
242
|
this.roles.includes("superuser")
|
|
249
243
|
) {
|
|
250
244
|
return true;
|
|
251
|
-
}
|
|
252
|
-
if (this.roles.includes("admin") || this.roles.includes("manager")) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
245
|
+
}
|
|
256
246
|
for (let i = 0; i < this.roles.length; i++) {
|
|
257
247
|
const role: string = this.roles[i];
|
|
258
248
|
if (role.includes(resourcename)) {
|
|
@@ -343,7 +333,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
343
333
|
},
|
|
344
334
|
};
|
|
345
335
|
}
|
|
346
|
-
}
|
|
336
|
+
}
|
|
347
337
|
// else
|
|
348
338
|
//
|
|
349
339
|
}
|
package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppPageIframe.vue.eta
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"
|
|
13
13
|
:title="pageInfo.title || t('miniAppLang.content')"
|
|
14
14
|
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-modals"
|
|
15
|
+
allow="clipboard-write"
|
|
15
16
|
referrerpolicy="origin"
|
|
16
17
|
loading="lazy"
|
|
17
18
|
@error="handleError"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
-
import { MiniAppAuthor } from 'src/simple-app/_core/resources/mini-app/mini-app.schema';
|
|
4
|
-
|
|
5
|
-
@ObjectType()
|
|
6
|
-
export class DeveloperPortalCreateAppDto {
|
|
7
|
-
@Field()
|
|
8
|
-
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
9
|
-
code: string;
|
|
10
|
-
|
|
11
|
-
@Field()
|
|
12
|
-
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
13
|
-
name: string;
|
|
14
|
-
|
|
15
|
-
@Field()
|
|
16
|
-
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
17
|
-
version: string;
|
|
18
|
-
|
|
19
|
-
@Field()
|
|
20
|
-
@ApiProperty({ type: MiniAppAuthor, required: true, default: '' })
|
|
21
|
-
author: MiniAppAuthor;
|
|
22
|
-
}
|