cabloy 5.1.103 → 5.1.105
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/.cabloy-version +1 -1
- package/.claude/skills/cabloy-backend-scaffold/references/follow-up-checklist.md +1 -1
- package/CHANGELOG.md +27 -0
- package/CLAUDE.md +1 -0
- package/cabloy-docs/backend/controller-aop-guide.md +2 -2
- package/cabloy-docs/backend/field-indexes.md +10 -1
- package/cabloy-docs/backend/menu-guide.md +30 -0
- package/cabloy-docs/frontend/a-model-under-the-hood.md +26 -4
- package/cabloy-docs/frontend/model-architecture.md +1 -1
- package/cabloy-docs/frontend/model-state-guide.md +122 -16
- package/cabloy-docs/frontend/ssr-init-data.md +12 -1
- package/cabloy-docs/frontend/use-state-data-best-practices.md +23 -0
- package/package.json +1 -1
- package/vona/packages-vona/vona/package.json +1 -1
- package/vona/pnpm-lock.yaml +31 -31
- package/vona/src/suite/a-home/modules/home-user/src/bean/eventListener.activate.ts +5 -4
- package/vona/src/suite/a-home/modules/home-user/src/bean/meta.version.ts +10 -6
- package/vona/src/suite/a-home/modules/home-user/src/config/config.ts +1 -1
- package/vona/src/suite/a-home/modules/home-user/src/controller/passport.ts +7 -7
- package/vona/src/suite/a-home/modules/home-user/src/entity/role.ts +4 -0
- package/vona/src/suite/a-home/modules/home-user/src/service/passportAdapter.ts +2 -2
- package/vona/src/suite/a-home/modules/home-user/src/service/roleAdapter.ts +5 -5
- package/vona/src/suite/a-training/modules/training-record/src/bean/ssrMenu.record.ts +1 -0
- package/vona/src/suite/a-training/modules/training-student/src/bean/ssrMenu.student.ts +1 -0
- package/vona/src/suite/cabloy-basic/modules/basic-siteadmin/src/bean/ssrMenu.home.ts +1 -0
- package/vona/src/suite/cabloy-basic/modules/basic-siteadmin/src/bean/ssrSite.admin.ts +5 -1
- package/vona/src/suite/cabloy-basic/modules/basic-siteweb/src/bean/ssrSite.web.ts +5 -1
- package/vona/src/suite-vendor/a-auth/modules/a-auth/package.json +1 -1
- package/vona/src/suite-vendor/a-auth/modules/a-auth/src/service/auth.ts +5 -1
- package/vona/src/suite-vendor/a-auth/package.json +1 -1
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/cli/ssrSite/boilerplate/{{sceneName}}.{{beanName}}.ts_ +5 -3
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/package.json +1 -1
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/bean/event.retrieveMenusSite.ts +2 -2
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/lib/beanSsrSiteBase.ts +33 -8
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/service/ssr.ts +46 -16
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/service/ssrHandler.ts +2 -4
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/types/env.ts +1 -0
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/types/ssrMenu.ts +10 -1
- package/vona/src/suite-vendor/a-cabloy/modules/a-ssr/src/types/ssrSite.ts +3 -1
- package/vona/src/suite-vendor/a-cabloy/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-permission/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/.metadata/index.ts +18 -2
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/bean/bean.permission.ts +6 -1
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/bean/event.retrievePermissionAction.ts +16 -0
- package/vona/src/suite-vendor/a-vona/modules/a-user/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/bean/bean.passport.ts +2 -2
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/lib/passport.ts +7 -4
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/types/passport.ts +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/types/role.ts +3 -1
- package/vona/src/suite-vendor/a-vona/package.json +1 -1
- package/zova/env/.env.cabloyBasicAdmin +2 -0
- package/zova/env/.env.cabloyBasicWeb +2 -0
- package/zova/packages-utils/zova-jsx/package.json +2 -2
- package/zova/packages-zova/zova/package.json +3 -3
- package/zova/packages-zova/zova-core/package.json +1 -1
- package/zova/packages-zova/zova-core/src/core/sys/sys.ts +3 -0
- package/zova/packages-zova/zova-core/src/types/utils/env.ts +1 -0
- package/zova/src/suite/a-home/modules/home-api/src/api/homeUserPassport.ts +19 -19
- package/zova/src/suite/a-home/modules/home-api/src/api/openapi/types.ts +11 -10
- package/zova/src/suite/a-home/modules/home-api/src/apiSchema/homeUserPassport.ts +5 -5
- package/zova/src/suite/a-home/modules/home-base/src/.metadata/page/errorAccessDenied.ts +9 -0
- package/zova/src/suite/a-home/modules/home-base/src/page/errorAccessDenied/controller.tsx +40 -0
- package/zova/src/suite/a-home/modules/home-base/src/routes.ts +9 -0
- package/zova/src/suite/a-home/modules/home-base/src/service/routerGuards.ts +21 -12
- package/zova/src/suite/a-home/modules/home-passport/src/model/passport.ts +7 -1
- package/zova/src/suite/a-home/modules/home-passport/src/monkey.ts +17 -3
- package/zova/src/suite-vendor/a-zova/modules/a-model/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-model/src/bean/bean.model/bean.model.useState.ts +6 -6
- package/zova/src/suite-vendor/a-zova/modules/a-model/src/bean/bean.model/bean.model.useStateGeneral.ts +5 -5
- package/zova/src/suite-vendor/a-zova/modules/a-model/src/monkey.ts +11 -2
- package/zova/src/suite-vendor/a-zova/modules/a-model/src/types/query.ts +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-router/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-router/src/monkeySys.ts +10 -1
- package/zova/src/suite-vendor/a-zova/modules/a-router/src/types/router.ts +1 -0
- package/zova/src/suite-vendor/a-zova/modules/a-routertabs/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-routertabs/src/model/tabs.ts +4 -4
- package/zova/src/suite-vendor/a-zova/modules/a-zova/package.json +2 -2
- package/zova/src/suite-vendor/a-zova/package.json +5 -5
|
@@ -53,9 +53,9 @@ export class BeanPassport extends BeanBase {
|
|
|
53
53
|
return !!user && !!user.activated;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
public async
|
|
56
|
+
public async isSystemAdmin(): Promise<boolean> {
|
|
57
57
|
const passport = this.current;
|
|
58
|
-
return await this.passportAdapter.
|
|
58
|
+
return await this.passportAdapter.isSystemAdmin(passport);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public async setCurrent(passport: IPassport | undefined) {
|
|
@@ -15,22 +15,25 @@ function RoleName(options?: Partial<IGuardOptionsRoleName>): ClassDecorator & Me
|
|
|
15
15
|
return Aspect.guard('a-user:roleName', options);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function SystemAdmin(
|
|
19
19
|
options?: Partial<Omit<IGuardOptionsRoleName, 'name'>>,
|
|
20
20
|
): ClassDecorator & MethodDecorator {
|
|
21
|
-
return Aspect.guard(
|
|
21
|
+
return Aspect.guard(
|
|
22
|
+
'a-user:roleName',
|
|
23
|
+
Object.assign({}, options, { name: 'systemAdmin' as const }),
|
|
24
|
+
);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export interface IDecoratorGroupPassport {
|
|
25
28
|
public: typeof Public;
|
|
26
29
|
activated: typeof Activated;
|
|
27
30
|
roleName: typeof RoleName;
|
|
28
|
-
|
|
31
|
+
systemAdmin: typeof SystemAdmin;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export const Passport: IDecoratorGroupPassport = {
|
|
32
35
|
public: Public,
|
|
33
36
|
activated: Activated,
|
|
34
37
|
roleName: RoleName,
|
|
35
|
-
|
|
38
|
+
systemAdmin: SystemAdmin,
|
|
36
39
|
} as unknown as IDecoratorGroupPassport;
|
|
@@ -11,7 +11,7 @@ export interface IPassport {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface IPassportAdapter {
|
|
14
|
-
|
|
14
|
+
isSystemAdmin(passport: IPassport | undefined): Promise<boolean>;
|
|
15
15
|
setCurrent(passport: IPassport | undefined): Promise<IPassport | undefined>;
|
|
16
16
|
serialize(passport: IPassport): Promise<IPayloadData>;
|
|
17
17
|
deserialize(payloadData: IPayloadData): Promise<IPassport | undefined>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { TableIdentity } from 'table-identity';
|
|
2
2
|
|
|
3
3
|
export interface IRoleNameRecord {
|
|
4
|
-
|
|
4
|
+
registeredUser: never;
|
|
5
|
+
systemAdmin: never;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export interface IRoleIdRecord {}
|
|
@@ -9,6 +10,7 @@ export interface IRoleIdRecord {}
|
|
|
9
10
|
export interface IRole {
|
|
10
11
|
id: TableIdentity;
|
|
11
12
|
name: string;
|
|
13
|
+
siteIds: string[];
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export interface IRoleAdapter {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-jsx",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.78",
|
|
4
4
|
"gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
|
|
5
5
|
"description": "Zova JSX",
|
|
6
6
|
"keywords": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@cabloy/word-utils": "^2.1.14",
|
|
51
51
|
"typestyle": "^2.4.0",
|
|
52
52
|
"vue": "^3.5.38",
|
|
53
|
-
"zova-core": "^5.1.
|
|
53
|
+
"zova-core": "^5.1.78"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"clean-package": "^2.2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.135",
|
|
4
4
|
"gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
|
|
5
5
|
"description": "A vue3 framework with ioc",
|
|
6
6
|
"keywords": [
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"postpack": "clean-package restore"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"zova-core": "^5.1.
|
|
49
|
-
"zova-suite-a-zova": "^5.1.
|
|
48
|
+
"zova-core": "^5.1.78",
|
|
49
|
+
"zova-suite-a-zova": "^5.1.134"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"clean-package": "^2.2.0",
|
|
@@ -132,6 +132,9 @@ export class ZovaSys {
|
|
|
132
132
|
private _prepareEnv(env: NodeJS.ProcessEnv, envRuntime?: Partial<ZovaConfigEnv>): ZovaConfigEnv {
|
|
133
133
|
const env2 = this._prepareEnv_Runtime(env, envRuntime);
|
|
134
134
|
const env3 = this._prepareEnv_Client(env2 as any);
|
|
135
|
+
if (!env3.SITE_ID?.trim()) {
|
|
136
|
+
throw new Error(`Should specify SITE_ID for Zova flavor: ${env3.META_FLAVOR}`);
|
|
137
|
+
}
|
|
135
138
|
return env3;
|
|
136
139
|
}
|
|
137
140
|
|
|
@@ -76,6 +76,17 @@ export type ApiApiHomeUserPassportmigrateRequestQuery =
|
|
|
76
76
|
export type ApiApiHomeUserPassportmigrateResponseBody =
|
|
77
77
|
paths[ApiApiHomeUserPassportmigratePath][ApiApiHomeUserPassportmigrateMethod]['responses']['200']['content']['application/json']['data'];
|
|
78
78
|
|
|
79
|
+
/** HomeUserPassport_refreshAuthToken */
|
|
80
|
+
export const ApiApiHomeUserPassportrefreshAuthTokenPath =
|
|
81
|
+
'/api/home/user/passport/refreshAuthToken';
|
|
82
|
+
export type ApiApiHomeUserPassportrefreshAuthTokenPath = '/api/home/user/passport/refreshAuthToken';
|
|
83
|
+
export type ApiApiHomeUserPassportrefreshAuthTokenMethod = 'post';
|
|
84
|
+
export type ApiApiHomeUserPassportrefreshAuthTokenRequestBody = {
|
|
85
|
+
refreshToken: string;
|
|
86
|
+
};
|
|
87
|
+
export type ApiApiHomeUserPassportrefreshAuthTokenResponseBody =
|
|
88
|
+
paths[ApiApiHomeUserPassportrefreshAuthTokenPath][ApiApiHomeUserPassportrefreshAuthTokenMethod]['responses']['200']['content']['application/json']['data'];
|
|
89
|
+
|
|
79
90
|
/** HomeUserPassport_createPassportJwtFromOauthCode */
|
|
80
91
|
export const ApiApiHomeUserPassportcreatePassportJwtFromOauthCodePath =
|
|
81
92
|
'/api/home/user/passport/createPassportJwtFromOauthCode';
|
|
@@ -88,17 +99,6 @@ export type ApiApiHomeUserPassportcreatePassportJwtFromOauthCodeRequestBody = {
|
|
|
88
99
|
export type ApiApiHomeUserPassportcreatePassportJwtFromOauthCodeResponseBody =
|
|
89
100
|
paths[ApiApiHomeUserPassportcreatePassportJwtFromOauthCodePath][ApiApiHomeUserPassportcreatePassportJwtFromOauthCodeMethod]['responses']['200']['content']['application/json']['data'];
|
|
90
101
|
|
|
91
|
-
/** HomeUserPassport_refreshAuthToken */
|
|
92
|
-
export const ApiApiHomeUserPassportrefreshAuthTokenPath =
|
|
93
|
-
'/api/home/user/passport/refreshAuthToken';
|
|
94
|
-
export type ApiApiHomeUserPassportrefreshAuthTokenPath = '/api/home/user/passport/refreshAuthToken';
|
|
95
|
-
export type ApiApiHomeUserPassportrefreshAuthTokenMethod = 'post';
|
|
96
|
-
export type ApiApiHomeUserPassportrefreshAuthTokenRequestBody = {
|
|
97
|
-
refreshToken: string;
|
|
98
|
-
};
|
|
99
|
-
export type ApiApiHomeUserPassportrefreshAuthTokenResponseBody =
|
|
100
|
-
paths[ApiApiHomeUserPassportrefreshAuthTokenPath][ApiApiHomeUserPassportrefreshAuthTokenMethod]['responses']['200']['content']['application/json']['data'];
|
|
101
|
-
|
|
102
102
|
/** HomeUserPassport_createTempAuthToken */
|
|
103
103
|
export const ApiApiHomeUserPassportcreateTempAuthTokenPath =
|
|
104
104
|
'/api/home/user/passport/createTempAuthToken';
|
|
@@ -179,23 +179,23 @@ export class ApiHomeUserPassport extends BeanApiBase {
|
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
body:
|
|
182
|
+
refreshAuthToken(
|
|
183
|
+
body: ApiApiHomeUserPassportrefreshAuthTokenRequestBody,
|
|
184
184
|
options?: IApiActionOptions,
|
|
185
185
|
) {
|
|
186
|
-
return this.$fetch.post<any,
|
|
187
|
-
|
|
186
|
+
return this.$fetch.post<any, ApiApiHomeUserPassportrefreshAuthTokenResponseBody>(
|
|
187
|
+
ApiApiHomeUserPassportrefreshAuthTokenPath,
|
|
188
188
|
body,
|
|
189
189
|
this.$configPrepare(OpenApiBaseURL(this.sys), options),
|
|
190
190
|
);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
body:
|
|
193
|
+
createPassportJwtFromOauthCode(
|
|
194
|
+
body: ApiApiHomeUserPassportcreatePassportJwtFromOauthCodeRequestBody,
|
|
195
195
|
options?: IApiActionOptions,
|
|
196
196
|
) {
|
|
197
|
-
return this.$fetch.post<any,
|
|
198
|
-
|
|
197
|
+
return this.$fetch.post<any, ApiApiHomeUserPassportcreatePassportJwtFromOauthCodeResponseBody>(
|
|
198
|
+
ApiApiHomeUserPassportcreatePassportJwtFromOauthCodePath,
|
|
199
199
|
body,
|
|
200
200
|
this.$configPrepare(OpenApiBaseURL(this.sys), options),
|
|
201
201
|
);
|
|
@@ -256,7 +256,7 @@ export interface paths {
|
|
|
256
256
|
patch?: never;
|
|
257
257
|
trace?: never;
|
|
258
258
|
};
|
|
259
|
-
'/api/home/user/passport/
|
|
259
|
+
'/api/home/user/passport/refreshAuthToken': {
|
|
260
260
|
parameters: {
|
|
261
261
|
query?: never;
|
|
262
262
|
header?: never;
|
|
@@ -265,14 +265,14 @@ export interface paths {
|
|
|
265
265
|
};
|
|
266
266
|
get?: never;
|
|
267
267
|
put?: never;
|
|
268
|
-
post: operations['
|
|
268
|
+
post: operations['HomeUserPassport_refreshAuthToken'];
|
|
269
269
|
delete?: never;
|
|
270
270
|
options?: never;
|
|
271
271
|
head?: never;
|
|
272
272
|
patch?: never;
|
|
273
273
|
trace?: never;
|
|
274
274
|
};
|
|
275
|
-
'/api/home/user/passport/
|
|
275
|
+
'/api/home/user/passport/createPassportJwtFromOauthCode': {
|
|
276
276
|
parameters: {
|
|
277
277
|
query?: never;
|
|
278
278
|
header?: never;
|
|
@@ -281,7 +281,7 @@ export interface paths {
|
|
|
281
281
|
};
|
|
282
282
|
get?: never;
|
|
283
283
|
put?: never;
|
|
284
|
-
post: operations['
|
|
284
|
+
post: operations['HomeUserPassport_createPassportJwtFromOauthCode'];
|
|
285
285
|
delete?: never;
|
|
286
286
|
options?: never;
|
|
287
287
|
head?: never;
|
|
@@ -1531,6 +1531,7 @@ export interface components {
|
|
|
1531
1531
|
id: number | string;
|
|
1532
1532
|
/** @description Role Name */
|
|
1533
1533
|
name: string;
|
|
1534
|
+
siteIds: string[];
|
|
1534
1535
|
};
|
|
1535
1536
|
'home-user.dto.passportJwt': {
|
|
1536
1537
|
passport: components['schemas']['home-user.dto.passport'];
|
|
@@ -3373,7 +3374,7 @@ export interface operations {
|
|
|
3373
3374
|
};
|
|
3374
3375
|
authToken: true;
|
|
3375
3376
|
};
|
|
3376
|
-
|
|
3377
|
+
HomeUserPassport_refreshAuthToken: {
|
|
3377
3378
|
parameters: {
|
|
3378
3379
|
query?: never;
|
|
3379
3380
|
header?: never;
|
|
@@ -3383,7 +3384,7 @@ export interface operations {
|
|
|
3383
3384
|
requestBody: {
|
|
3384
3385
|
content: {
|
|
3385
3386
|
'application/json': {
|
|
3386
|
-
|
|
3387
|
+
refreshToken: string;
|
|
3387
3388
|
};
|
|
3388
3389
|
};
|
|
3389
3390
|
};
|
|
@@ -3396,13 +3397,13 @@ export interface operations {
|
|
|
3396
3397
|
'application/json': {
|
|
3397
3398
|
code: string;
|
|
3398
3399
|
message: string;
|
|
3399
|
-
data: components['schemas']['
|
|
3400
|
+
data: components['schemas']['a-jwt.dto.jwtToken'];
|
|
3400
3401
|
};
|
|
3401
3402
|
};
|
|
3402
3403
|
};
|
|
3403
3404
|
};
|
|
3404
3405
|
};
|
|
3405
|
-
|
|
3406
|
+
HomeUserPassport_createPassportJwtFromOauthCode: {
|
|
3406
3407
|
parameters: {
|
|
3407
3408
|
query?: never;
|
|
3408
3409
|
header?: never;
|
|
@@ -3412,7 +3413,7 @@ export interface operations {
|
|
|
3412
3413
|
requestBody: {
|
|
3413
3414
|
content: {
|
|
3414
3415
|
'application/json': {
|
|
3415
|
-
|
|
3416
|
+
code: string;
|
|
3416
3417
|
};
|
|
3417
3418
|
};
|
|
3418
3419
|
};
|
|
@@ -3425,7 +3426,7 @@ export interface operations {
|
|
|
3425
3426
|
'application/json': {
|
|
3426
3427
|
code: string;
|
|
3427
3428
|
message: string;
|
|
3428
|
-
data: components['schemas']['
|
|
3429
|
+
data: components['schemas']['home-user.dto.passportJwt'];
|
|
3429
3430
|
};
|
|
3430
3431
|
};
|
|
3431
3432
|
};
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
ApiApiHomeUserPassportloginOauthPath,
|
|
12
12
|
ApiApiHomeUserPassportassociatePath,
|
|
13
13
|
ApiApiHomeUserPassportmigratePath,
|
|
14
|
-
ApiApiHomeUserPassportcreatePassportJwtFromOauthCodePath,
|
|
15
14
|
ApiApiHomeUserPassportrefreshAuthTokenPath,
|
|
15
|
+
ApiApiHomeUserPassportcreatePassportJwtFromOauthCodePath,
|
|
16
16
|
ApiApiHomeUserPassportcreateTempAuthTokenPath,
|
|
17
17
|
} from '../api/homeUserPassport.js';
|
|
18
18
|
|
|
@@ -46,6 +46,10 @@ export class ApiSchemaHomeUserPassport extends BeanBase {
|
|
|
46
46
|
return this.$sdk.createApiSchemas(ApiApiHomeUserPassportmigratePath, 'get', options);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
refreshAuthToken(options?: IApiSchemaOptions) {
|
|
50
|
+
return this.$sdk.createApiSchemas(ApiApiHomeUserPassportrefreshAuthTokenPath, 'post', options);
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
createPassportJwtFromOauthCode(options?: IApiSchemaOptions) {
|
|
50
54
|
return this.$sdk.createApiSchemas(
|
|
51
55
|
ApiApiHomeUserPassportcreatePassportJwtFromOauthCodePath,
|
|
@@ -54,10 +58,6 @@ export class ApiSchemaHomeUserPassport extends BeanBase {
|
|
|
54
58
|
);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
refreshAuthToken(options?: IApiSchemaOptions) {
|
|
58
|
-
return this.$sdk.createApiSchemas(ApiApiHomeUserPassportrefreshAuthTokenPath, 'post', options);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
61
|
createTempAuthToken(options?: IApiSchemaOptions) {
|
|
62
62
|
return this.$sdk.createApiSchemas(
|
|
63
63
|
ApiApiHomeUserPassportcreateTempAuthTokenPath,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createZovaComponentPage } from 'zova';
|
|
2
|
+
|
|
3
|
+
import { ControllerPageErrorAccessDenied } from '../../page/errorAccessDenied/controller.jsx';
|
|
4
|
+
|
|
5
|
+
export const ZPageErrorAccessDenied = createZovaComponentPage(
|
|
6
|
+
ControllerPageErrorAccessDenied,
|
|
7
|
+
undefined,
|
|
8
|
+
undefined,
|
|
9
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { classes } from 'typestyle';
|
|
2
|
+
import { BeanControllerPageBase } from 'zova';
|
|
3
|
+
import { Controller } from 'zova-module-a-bean';
|
|
4
|
+
|
|
5
|
+
@Controller()
|
|
6
|
+
export class ControllerPageErrorAccessDenied extends BeanControllerPageBase {
|
|
7
|
+
cTitle: string;
|
|
8
|
+
cDescription: string;
|
|
9
|
+
|
|
10
|
+
protected async __init__() {
|
|
11
|
+
this.cTitle = this.$style({
|
|
12
|
+
fontSize: '30vh',
|
|
13
|
+
});
|
|
14
|
+
this.cDescription = classes(
|
|
15
|
+
'text-3xl',
|
|
16
|
+
this.$style({
|
|
17
|
+
opacity: '0.4',
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected render() {
|
|
23
|
+
return (
|
|
24
|
+
<div class="text-center">
|
|
25
|
+
<div>
|
|
26
|
+
<div class={this.cTitle}>403</div>
|
|
27
|
+
<div class={this.cDescription}>Access denied.</div>
|
|
28
|
+
<button
|
|
29
|
+
class="btn btn-primary"
|
|
30
|
+
onClick={() => {
|
|
31
|
+
this.app.$gotoHome();
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
Go Home
|
|
35
|
+
</button>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IModuleRoute } from 'zova-module-a-router';
|
|
2
2
|
|
|
3
3
|
import { ZPageAuthCallback } from './.metadata/page/authCallback.js';
|
|
4
|
+
import { ZPageErrorAccessDenied } from './.metadata/page/errorAccessDenied.js';
|
|
4
5
|
import { ZPageErrorExpired } from './.metadata/page/errorExpired.js';
|
|
5
6
|
import { ZPageErrorNotFound } from './.metadata/page/errorNotFound.js';
|
|
6
7
|
|
|
@@ -14,6 +15,14 @@ export const routes: IModuleRoute[] = [
|
|
|
14
15
|
requiresAuth: false,
|
|
15
16
|
},
|
|
16
17
|
},
|
|
18
|
+
{
|
|
19
|
+
path: 'errorAccessDenied',
|
|
20
|
+
component: ZPageErrorAccessDenied,
|
|
21
|
+
meta: {
|
|
22
|
+
layout: 'empty',
|
|
23
|
+
requiresAuth: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
17
26
|
{
|
|
18
27
|
path: 'errorNotFound',
|
|
19
28
|
component: ZPageErrorNotFound,
|
|
@@ -14,11 +14,9 @@ export class ServiceRouterGuards extends BeanRouterGuardsBase {
|
|
|
14
14
|
|
|
15
15
|
protected onRouterGuards(router: BeanRouter) {
|
|
16
16
|
router.beforeEach(async to => {
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
!this.$passport.isAuthenticated
|
|
21
|
-
) {
|
|
17
|
+
if (to.meta.requiresAuth === false) return;
|
|
18
|
+
if (this.sys.config.ssr.cookieDisabledOnServer) return;
|
|
19
|
+
if (!this.$passport.isAuthenticated) {
|
|
22
20
|
const [_res, err] = await catchError(() => {
|
|
23
21
|
return this.$passport.ensurePassport();
|
|
24
22
|
});
|
|
@@ -26,14 +24,25 @@ export class ServiceRouterGuards extends BeanRouterGuardsBase {
|
|
|
26
24
|
this.$errorHandler(err, 'onRouterGuards');
|
|
27
25
|
return false;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
}
|
|
28
|
+
if (!this.$passport.isAuthenticated) {
|
|
29
|
+
try {
|
|
30
|
+
this.app.$gotoLogin(to.fullPath);
|
|
31
|
+
} catch (err: any) {
|
|
32
|
+
this.$errorHandler(err);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const siteId = this.sys.env.SITE_ID;
|
|
37
|
+
const siteAdmitted =
|
|
38
|
+
!!siteId && !!this.$passport.roles?.some(role => role.siteIds.includes(siteId));
|
|
39
|
+
if (!siteAdmitted) {
|
|
40
|
+
try {
|
|
41
|
+
this.app.$gotoAccessDenied();
|
|
42
|
+
} catch (err: any) {
|
|
43
|
+
this.$errorHandler(err);
|
|
36
44
|
}
|
|
45
|
+
return false;
|
|
37
46
|
}
|
|
38
47
|
});
|
|
39
48
|
router.beforeResolve(async to => {
|
|
@@ -28,7 +28,9 @@ export class ModelPassport extends BeanModelBase {
|
|
|
28
28
|
expireTime?: number;
|
|
29
29
|
schemaLogin?: SchemaObject;
|
|
30
30
|
|
|
31
|
-
protected async __init__() {
|
|
31
|
+
protected async __init__() {}
|
|
32
|
+
|
|
33
|
+
async appInitialize() {
|
|
32
34
|
this.schemaLogin = this.$computed(() => {
|
|
33
35
|
return this.apiSchemasLogin.requestBody;
|
|
34
36
|
});
|
|
@@ -167,6 +169,10 @@ export class ModelPassport extends BeanModelBase {
|
|
|
167
169
|
return this.passport?.roles;
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
get isSystemAdmin() {
|
|
173
|
+
return !!this.passport?.roles.some(item => item.name === 'systemAdmin');
|
|
174
|
+
}
|
|
175
|
+
|
|
170
176
|
async getJwtInfo(): Promise<IJwtInfo | undefined> {
|
|
171
177
|
if (!this.accessToken) return undefined;
|
|
172
178
|
return {
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { IModule } from '@cabloy/module-info';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
BeanBase,
|
|
4
|
+
BeanContainer,
|
|
5
|
+
IMonkeyAppInitialize,
|
|
6
|
+
IMonkeyBeanInit,
|
|
7
|
+
IMonkeyModule,
|
|
8
|
+
} from 'zova';
|
|
3
9
|
|
|
4
10
|
import { BeanSimple } from 'zova';
|
|
5
11
|
|
|
6
12
|
import type { ModelPassport } from './model/passport.js';
|
|
7
13
|
|
|
8
|
-
export class Monkey
|
|
14
|
+
export class Monkey
|
|
15
|
+
extends BeanSimple
|
|
16
|
+
implements IMonkeyAppInitialize, IMonkeyModule, IMonkeyBeanInit
|
|
17
|
+
{
|
|
9
18
|
private _moduleSelf: IModule;
|
|
10
19
|
private $$modelPassport: ModelPassport;
|
|
11
20
|
|
|
@@ -14,13 +23,18 @@ export class Monkey extends BeanSimple implements IMonkeyModule, IMonkeyBeanInit
|
|
|
14
23
|
this._moduleSelf = moduleSelf;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
|
-
async getModelPassport() {
|
|
26
|
+
private async getModelPassport() {
|
|
18
27
|
if (!this.$$modelPassport) {
|
|
19
28
|
this.$$modelPassport = await this.bean._getBean('home-passport.model.passport', true);
|
|
20
29
|
}
|
|
21
30
|
return this.$$modelPassport;
|
|
22
31
|
}
|
|
23
32
|
|
|
33
|
+
async appInitialize() {
|
|
34
|
+
const modelPassport = await this.getModelPassport();
|
|
35
|
+
await modelPassport.appInitialize();
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
async moduleLoading(_module: IModule) {}
|
|
25
39
|
async moduleLoaded(module: IModule) {
|
|
26
40
|
// self
|
package/zova/src/suite-vendor/a-zova/modules/a-model/src/bean/bean.model/bean.model.useState.ts
CHANGED
|
@@ -28,11 +28,11 @@ export class BeanModelUseState extends BeanModelUseQuery {
|
|
|
28
28
|
private [SymbolUseQueries]: Record<string, unknown> = {};
|
|
29
29
|
private [SymbolUseComputeds]: Record<string, unknown> = {};
|
|
30
30
|
|
|
31
|
-
async $
|
|
32
|
-
return await
|
|
31
|
+
async $ensureStateLocalAsync<T>(state: T): Promise<T> {
|
|
32
|
+
return await state;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
$
|
|
35
|
+
$useStateLocalAsync<
|
|
36
36
|
TQueryFnData = unknown,
|
|
37
37
|
TError = DefaultError,
|
|
38
38
|
TData = TQueryFnData,
|
|
@@ -41,7 +41,7 @@ export class BeanModelUseState extends BeanModelUseQuery {
|
|
|
41
41
|
options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
42
42
|
queryClient?: QueryClient,
|
|
43
43
|
): TData;
|
|
44
|
-
$
|
|
44
|
+
$useStateLocalAsync<
|
|
45
45
|
TQueryFnData = unknown,
|
|
46
46
|
TError = DefaultError,
|
|
47
47
|
TData = TQueryFnData,
|
|
@@ -50,7 +50,7 @@ export class BeanModelUseState extends BeanModelUseQuery {
|
|
|
50
50
|
options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
51
51
|
queryClient?: QueryClient,
|
|
52
52
|
): TData;
|
|
53
|
-
$
|
|
53
|
+
$useStateLocalAsync<
|
|
54
54
|
TQueryFnData = unknown,
|
|
55
55
|
TError = DefaultError,
|
|
56
56
|
TData = TQueryFnData,
|
|
@@ -59,7 +59,7 @@ export class BeanModelUseState extends BeanModelUseQuery {
|
|
|
59
59
|
options: UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,
|
|
60
60
|
queryClient?: QueryClient,
|
|
61
61
|
): TData;
|
|
62
|
-
$
|
|
62
|
+
$useStateLocalAsync(options, queryClient) {
|
|
63
63
|
options = deepExtend(
|
|
64
64
|
{
|
|
65
65
|
meta: {
|
|
@@ -23,7 +23,7 @@ export class BeanModelUseStateGeneral extends BeanModelUseState {
|
|
|
23
23
|
TData = TQueryFnData,
|
|
24
24
|
TQueryKey extends QueryKey = QueryKey,
|
|
25
25
|
>(
|
|
26
|
-
stateType: '
|
|
26
|
+
stateType: 'localAsync' | 'local' | 'cookie' | 'mem',
|
|
27
27
|
options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
28
28
|
queryClient?: QueryClient,
|
|
29
29
|
): TData;
|
|
@@ -33,7 +33,7 @@ export class BeanModelUseStateGeneral extends BeanModelUseState {
|
|
|
33
33
|
TData = TQueryFnData,
|
|
34
34
|
TQueryKey extends QueryKey = QueryKey,
|
|
35
35
|
>(
|
|
36
|
-
stateType: '
|
|
36
|
+
stateType: 'localAsync' | 'local' | 'cookie' | 'mem',
|
|
37
37
|
options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
38
38
|
queryClient?: QueryClient,
|
|
39
39
|
): TData;
|
|
@@ -43,7 +43,7 @@ export class BeanModelUseStateGeneral extends BeanModelUseState {
|
|
|
43
43
|
TData = TQueryFnData,
|
|
44
44
|
TQueryKey extends QueryKey = QueryKey,
|
|
45
45
|
>(
|
|
46
|
-
stateType: '
|
|
46
|
+
stateType: 'localAsync' | 'local' | 'cookie' | 'mem',
|
|
47
47
|
options: UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,
|
|
48
48
|
queryClient?: QueryClient,
|
|
49
49
|
): TData;
|
|
@@ -79,8 +79,8 @@ export class BeanModelUseStateGeneral extends BeanModelUseState {
|
|
|
79
79
|
): UnwrapNestedRefs<UseQueryReturnType<TData, TError>>;
|
|
80
80
|
$useState(stateType: StateType, options, queryClient) {
|
|
81
81
|
switch (stateType) {
|
|
82
|
-
case '
|
|
83
|
-
return this.$
|
|
82
|
+
case 'localAsync':
|
|
83
|
+
return this.$useStateLocalAsync(options, queryClient);
|
|
84
84
|
case 'local':
|
|
85
85
|
return this.$useStateLocal(options, queryClient);
|
|
86
86
|
case 'cookie':
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { IModule } from '@cabloy/module-info';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
BeanBase,
|
|
4
|
+
BeanContainer,
|
|
5
|
+
IMonkeyAppInitialize,
|
|
6
|
+
IMonkeyBeanInit,
|
|
7
|
+
IMonkeyModule,
|
|
8
|
+
} from 'zova';
|
|
3
9
|
|
|
4
10
|
import { useQueryClient } from '@tanstack/vue-query';
|
|
5
11
|
import { markRaw } from 'vue';
|
|
@@ -7,7 +13,10 @@ import { BeanSimple } from 'zova';
|
|
|
7
13
|
|
|
8
14
|
import { ServiceStorage } from './service/storage.js';
|
|
9
15
|
|
|
10
|
-
export class Monkey
|
|
16
|
+
export class Monkey
|
|
17
|
+
extends BeanSimple
|
|
18
|
+
implements IMonkeyAppInitialize, IMonkeyModule, IMonkeyBeanInit
|
|
19
|
+
{
|
|
11
20
|
private _moduleSelf: IModule;
|
|
12
21
|
private _storage: ServiceStorage;
|
|
13
22
|
|