vona-module-a-user 5.0.15 → 5.0.17
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/dist/.metadata/index.d.ts +47 -48
- package/dist/config/config.d.ts +1 -1
- package/dist/index.js +127 -127
- package/package.json +1 -1
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type { BeanAuthInner } from '../bean/bean.authInner.ts';
|
|
6
|
-
import type { BeanPassport } from '../bean/bean.passport.ts';
|
|
7
|
-
import type { BeanRoleInner } from '../bean/bean.roleInner.ts';
|
|
8
|
-
import type { BeanUserInner } from '../bean/bean.userInner.ts';
|
|
9
|
-
/** event: end */
|
|
10
|
-
/** event: begin */
|
|
11
|
-
import type { EventCreateUserAnonymous } from '../bean/event.createUserAnonymous.ts';
|
|
12
|
-
/** event: end */
|
|
13
|
-
/** event: begin */
|
|
14
|
-
import type { TypeEventCreateUserAnonymousData, TypeEventCreateUserAnonymousResult } from '../bean/event.createUserAnonymous.ts';
|
|
15
|
-
import type { EventSignin } from '../bean/event.signin.ts';
|
|
16
|
-
import type { TypeEventSigninData, TypeEventSigninResult } from '../bean/event.signin.ts';
|
|
17
|
-
import type { EventSignout } from '../bean/event.signout.ts';
|
|
18
|
-
import type { TypeEventSignoutData, TypeEventSignoutResult } from '../bean/event.signout.ts';
|
|
19
|
-
/** guard: end */
|
|
20
|
-
/** bean: begin */
|
|
1
|
+
/** guard: begin */
|
|
2
|
+
export * from '../bean/guard.passport.ts';
|
|
3
|
+
export * from '../bean/guard.roleName.ts';
|
|
4
|
+
export * from '../bean/guard.userName.ts';
|
|
21
5
|
import type { IGuardOptionsPassport } from '../bean/guard.passport.ts';
|
|
22
6
|
import type { IGuardOptionsRoleName } from '../bean/guard.roleName.ts';
|
|
23
7
|
import type { IGuardOptionsUserName } from '../bean/guard.userName.ts';
|
|
24
|
-
import type { config } from '../config/config.ts';
|
|
25
|
-
/** config: end */
|
|
26
|
-
/** scope: begin */
|
|
27
|
-
import { BeanScopeBase } from 'vona';
|
|
28
|
-
import 'vona';
|
|
29
|
-
import 'vona';
|
|
30
|
-
import 'vona';
|
|
31
|
-
import 'vona';
|
|
32
8
|
import 'vona';
|
|
33
|
-
import 'vona';
|
|
34
|
-
export * from '../bean/bean.authInner.ts';
|
|
35
|
-
export * from '../bean/bean.passport.ts';
|
|
36
|
-
export * from '../bean/bean.roleInner.ts';
|
|
37
9
|
declare module 'vona-module-a-aspect' {
|
|
38
10
|
interface IGuardRecordGlobal {
|
|
39
11
|
'a-user:passport': IGuardOptionsPassport;
|
|
@@ -51,12 +23,13 @@ declare module 'vona-module-a-user' {
|
|
|
51
23
|
interface GuardUserName {
|
|
52
24
|
}
|
|
53
25
|
}
|
|
26
|
+
/** guard: end */
|
|
27
|
+
/** bean: begin */
|
|
28
|
+
export * from '../bean/bean.authInner.ts';
|
|
29
|
+
export * from '../bean/bean.passport.ts';
|
|
30
|
+
export * from '../bean/bean.roleInner.ts';
|
|
54
31
|
export * from '../bean/bean.userInner.ts';
|
|
55
|
-
|
|
56
|
-
/** event: begin */
|
|
57
|
-
export * from '../bean/event.createUserAnonymous.ts';
|
|
58
|
-
export * from '../bean/event.signin.ts';
|
|
59
|
-
export * from '../bean/event.signout.ts';
|
|
32
|
+
import 'vona';
|
|
60
33
|
declare module 'vona' {
|
|
61
34
|
}
|
|
62
35
|
declare module 'vona-module-a-user' {
|
|
@@ -69,18 +42,27 @@ declare module 'vona-module-a-user' {
|
|
|
69
42
|
interface BeanUserInner {
|
|
70
43
|
}
|
|
71
44
|
}
|
|
45
|
+
/** bean: end */
|
|
46
|
+
/** bean: begin */
|
|
47
|
+
import type { BeanAuthInner } from '../bean/bean.authInner.ts';
|
|
48
|
+
import type { BeanPassport } from '../bean/bean.passport.ts';
|
|
49
|
+
import type { BeanRoleInner } from '../bean/bean.roleInner.ts';
|
|
50
|
+
import type { BeanUserInner } from '../bean/bean.userInner.ts';
|
|
51
|
+
import 'vona';
|
|
72
52
|
declare module 'vona' {
|
|
73
53
|
interface IBeanRecordGlobal {
|
|
74
|
-
authInner: BeanAuthInner;
|
|
75
|
-
passport: BeanPassport;
|
|
76
|
-
roleInner: BeanRoleInner;
|
|
77
|
-
userInner: BeanUserInner;
|
|
54
|
+
'authInner': BeanAuthInner;
|
|
55
|
+
'passport': BeanPassport;
|
|
56
|
+
'roleInner': BeanRoleInner;
|
|
57
|
+
'userInner': BeanUserInner;
|
|
78
58
|
}
|
|
79
59
|
}
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
export * from '../bean/
|
|
83
|
-
export * from '../bean/
|
|
60
|
+
/** bean: end */
|
|
61
|
+
/** event: begin */
|
|
62
|
+
export * from '../bean/event.createUserAnonymous.ts';
|
|
63
|
+
export * from '../bean/event.signin.ts';
|
|
64
|
+
export * from '../bean/event.signout.ts';
|
|
65
|
+
import 'vona';
|
|
84
66
|
declare module 'vona' {
|
|
85
67
|
}
|
|
86
68
|
declare module 'vona-module-a-user' {
|
|
@@ -91,11 +73,22 @@ declare module 'vona-module-a-user' {
|
|
|
91
73
|
interface EventSignout {
|
|
92
74
|
}
|
|
93
75
|
}
|
|
76
|
+
/** event: end */
|
|
77
|
+
/** event: begin */
|
|
78
|
+
import type { EventCreateUserAnonymous } from '../bean/event.createUserAnonymous.ts';
|
|
79
|
+
import type { EventSignin } from '../bean/event.signin.ts';
|
|
80
|
+
import type { EventSignout } from '../bean/event.signout.ts';
|
|
94
81
|
export interface IModuleEvent {
|
|
95
|
-
createUserAnonymous: EventCreateUserAnonymous;
|
|
96
|
-
signin: EventSignin;
|
|
97
|
-
signout: EventSignout;
|
|
82
|
+
'createUserAnonymous': EventCreateUserAnonymous;
|
|
83
|
+
'signin': EventSignin;
|
|
84
|
+
'signout': EventSignout;
|
|
98
85
|
}
|
|
86
|
+
/** event: end */
|
|
87
|
+
/** event: begin */
|
|
88
|
+
import type { TypeEventCreateUserAnonymousData, TypeEventCreateUserAnonymousResult } from '../bean/event.createUserAnonymous.ts';
|
|
89
|
+
import type { TypeEventSigninData, TypeEventSigninResult } from '../bean/event.signin.ts';
|
|
90
|
+
import type { TypeEventSignoutData, TypeEventSignoutResult } from '../bean/event.signout.ts';
|
|
91
|
+
import type { EventOn } from 'vona-module-a-event';
|
|
99
92
|
declare module 'vona-module-a-event' {
|
|
100
93
|
interface IEventRecord {
|
|
101
94
|
'a-user:createUserAnonymous': EventOn<TypeEventCreateUserAnonymousData, TypeEventCreateUserAnonymousResult>;
|
|
@@ -106,6 +99,7 @@ declare module 'vona-module-a-event' {
|
|
|
106
99
|
/** event: end */
|
|
107
100
|
/** meta: begin */
|
|
108
101
|
export * from '../bean/meta.printTip.ts';
|
|
102
|
+
import 'vona';
|
|
109
103
|
declare module 'vona' {
|
|
110
104
|
interface IMetaRecord {
|
|
111
105
|
'a-user:printTip': never;
|
|
@@ -118,6 +112,10 @@ declare module 'vona-module-a-user' {
|
|
|
118
112
|
/** meta: end */
|
|
119
113
|
/** config: begin */
|
|
120
114
|
export * from '../config/config.ts';
|
|
115
|
+
import type { config } from '../config/config.ts';
|
|
116
|
+
/** config: end */
|
|
117
|
+
/** scope: begin */
|
|
118
|
+
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig } from 'vona';
|
|
121
119
|
export declare class ScopeModuleAUser extends BeanScopeBase {
|
|
122
120
|
}
|
|
123
121
|
export interface ScopeModuleAUser {
|
|
@@ -125,6 +123,7 @@ export interface ScopeModuleAUser {
|
|
|
125
123
|
config: TypeModuleConfig<typeof config>;
|
|
126
124
|
event: IModuleEvent;
|
|
127
125
|
}
|
|
126
|
+
import 'vona';
|
|
128
127
|
declare module 'vona' {
|
|
129
128
|
interface IBeanScopeRecord {
|
|
130
129
|
'a-user': ScopeModuleAUser;
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VonaApplication } from 'vona';
|
|
2
|
-
import type { IServiceRecord } from 'vona-module-a-
|
|
2
|
+
import type { IServiceRecord } from 'vona-module-a-bean';
|
|
3
3
|
import type { TypeAuthToken } from '../types/auth.ts';
|
|
4
4
|
export declare function config(_app: VonaApplication): {
|
|
5
5
|
passport: {
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,54 @@
|
|
|
1
1
|
import { BeanInfo, BeanBase, beanFullNameFromOnionName, BeanScopeBase } from 'vona';
|
|
2
|
-
import { Bean, Scope } from 'vona-module-a-bean';
|
|
3
2
|
import { catchError } from '@cabloy/utils';
|
|
4
|
-
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
5
3
|
import { Guard, Aspect } from 'vona-module-a-aspect';
|
|
4
|
+
import { Bean, Scope } from 'vona-module-a-bean';
|
|
5
|
+
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
6
6
|
import { Meta } from 'vona-module-a-meta';
|
|
7
7
|
|
|
8
8
|
var _dec$b, _dec2$b, _class$b;
|
|
9
|
-
let
|
|
9
|
+
let GuardPassport = (_dec$b = Guard({
|
|
10
|
+
global: true,
|
|
11
|
+
public: false,
|
|
12
|
+
checkAuthToken: true
|
|
13
|
+
}), _dec2$b = BeanInfo({
|
|
10
14
|
module: "a-user"
|
|
11
|
-
}), _dec$b(_class$b = _dec2$b(_class$b = class
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
}), _dec$b(_class$b = _dec2$b(_class$b = class GuardPassport extends BeanBase {
|
|
16
|
+
async execute(options, next) {
|
|
17
|
+
// auth token
|
|
18
|
+
if (!this.bean.passport.getCurrent()) {
|
|
19
|
+
if (options.checkAuthToken) {
|
|
20
|
+
// will return undefined if no accessToken, so not check options.public
|
|
21
|
+
const [_, err] = await catchError(() => {
|
|
22
|
+
return this.bean.passport.checkAuthToken();
|
|
23
|
+
});
|
|
24
|
+
if (err && !options.public) throw err;
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
// check current
|
|
28
|
+
if (!this.bean.passport.getCurrent()) {
|
|
29
|
+
await this.bean.passport.signinWithAnonymous();
|
|
30
|
+
}
|
|
31
|
+
if (!options.public && !this.bean.passport.isAuthenticated) {
|
|
32
|
+
// return false;
|
|
33
|
+
// 401 for this guard,403 for the next guards
|
|
34
|
+
return this.app.throw(401);
|
|
35
|
+
}
|
|
36
|
+
// check innerAccess
|
|
37
|
+
if (this.ctx.innerAccess) return true;
|
|
38
|
+
// next
|
|
39
|
+
return next();
|
|
26
40
|
}
|
|
27
41
|
}) || _class$b) || _class$b);
|
|
28
42
|
|
|
29
|
-
let
|
|
30
|
-
function
|
|
31
|
-
|
|
43
|
+
let __roleAdapter;
|
|
44
|
+
function setRoleAdapter(roleAdapter) {
|
|
45
|
+
__roleAdapter = roleAdapter;
|
|
32
46
|
}
|
|
33
|
-
function $
|
|
34
|
-
return
|
|
47
|
+
function $getRoleId(role) {
|
|
48
|
+
return __roleAdapter.getRoleId(role);
|
|
35
49
|
}
|
|
36
|
-
function $
|
|
37
|
-
return
|
|
50
|
+
function $getRoleName(role) {
|
|
51
|
+
return __roleAdapter.getRoleName(role);
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
let __userAdapter;
|
|
@@ -61,9 +75,81 @@ function $getUserIdSystem(_userName, userId) {
|
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
var _dec$a, _dec2$a, _class$a;
|
|
64
|
-
let
|
|
78
|
+
let GuardRoleName = (_dec$a = Guard({
|
|
79
|
+
passWhenMatched: true
|
|
80
|
+
}), _dec2$a = BeanInfo({
|
|
81
|
+
module: "a-user"
|
|
82
|
+
}), _dec$a(_class$a = _dec2$a(_class$a = class GuardRoleName extends BeanBase {
|
|
83
|
+
async execute(options, next) {
|
|
84
|
+
if (!options.name) return this.app.throw(403);
|
|
85
|
+
const user = this.bean.passport.getCurrentUser();
|
|
86
|
+
if (!user || $getUserAnonymous(user)) return this.app.throw(403);
|
|
87
|
+
const roles = this.bean.passport.getCurrentRoles();
|
|
88
|
+
if (!roles) return this.app.throw(403);
|
|
89
|
+
const roleNames = roles?.map(item => $getRoleName(item));
|
|
90
|
+
const optionsName = Array.isArray(options.name) ? options.name : [options.name];
|
|
91
|
+
if (!roleNames.some(roleName => optionsName.includes(roleName))) return this.app.throw(403);
|
|
92
|
+
if (options.passWhenMatched) return true;
|
|
93
|
+
// next
|
|
94
|
+
return next();
|
|
95
|
+
}
|
|
96
|
+
}) || _class$a) || _class$a);
|
|
97
|
+
|
|
98
|
+
var _dec$9, _dec2$9, _class$9;
|
|
99
|
+
let GuardUserName = (_dec$9 = Guard({
|
|
100
|
+
passWhenMatched: true
|
|
101
|
+
}), _dec2$9 = BeanInfo({
|
|
102
|
+
module: "a-user"
|
|
103
|
+
}), _dec$9(_class$9 = _dec2$9(_class$9 = class GuardUserName extends BeanBase {
|
|
104
|
+
async execute(options, next) {
|
|
105
|
+
if (!options.name) return this.app.throw(403);
|
|
106
|
+
const user = this.bean.passport.getCurrentUser();
|
|
107
|
+
if (!user || $getUserAnonymous(user)) return this.app.throw(403);
|
|
108
|
+
const userName = $getUserName(user);
|
|
109
|
+
const optionsName = Array.isArray(options.name) ? options.name : [options.name];
|
|
110
|
+
if (!optionsName.includes(userName)) return this.app.throw(403);
|
|
111
|
+
if (options.passWhenMatched) return true;
|
|
112
|
+
// next
|
|
113
|
+
return next();
|
|
114
|
+
}
|
|
115
|
+
}) || _class$9) || _class$9);
|
|
116
|
+
|
|
117
|
+
var _dec$8, _dec2$8, _class$8;
|
|
118
|
+
let BeanAuthInner = (_dec$8 = Bean(), _dec2$8 = BeanInfo({
|
|
119
|
+
module: "a-user"
|
|
120
|
+
}), _dec$8(_class$8 = _dec2$8(_class$8 = class BeanAuthInner extends BeanBase {
|
|
121
|
+
constructor(...args) {
|
|
122
|
+
super(...args);
|
|
123
|
+
this._authInnerAdapter = void 0;
|
|
124
|
+
}
|
|
125
|
+
get authInnerAdapter() {
|
|
126
|
+
if (!this._authInnerAdapter) {
|
|
127
|
+
const beanFullName = beanFullNameFromOnionName(this.scope.config.adapter.authInner, 'service');
|
|
128
|
+
this._authInnerAdapter = this.bean._getBean(beanFullName);
|
|
129
|
+
}
|
|
130
|
+
return this._authInnerAdapter;
|
|
131
|
+
}
|
|
132
|
+
async findOne(auth) {
|
|
133
|
+
if (String(auth.id).charAt(0) === '-') return auth;
|
|
134
|
+
return await this.authInnerAdapter.findOne(auth);
|
|
135
|
+
}
|
|
136
|
+
}) || _class$8) || _class$8);
|
|
137
|
+
|
|
138
|
+
let __authAdapter;
|
|
139
|
+
function setAuthAdapter(authAdapter) {
|
|
140
|
+
__authAdapter = authAdapter;
|
|
141
|
+
}
|
|
142
|
+
function $getAuthId(user) {
|
|
143
|
+
return __authAdapter.getAuthId(user);
|
|
144
|
+
}
|
|
145
|
+
function $getAuthIdSystem(_authName, authId) {
|
|
146
|
+
return authId;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var _dec$7, _dec2$7, _class$7;
|
|
150
|
+
let BeanPassport = (_dec$7 = Bean(), _dec2$7 = BeanInfo({
|
|
65
151
|
module: "a-user"
|
|
66
|
-
}), _dec$
|
|
152
|
+
}), _dec$7(_class$7 = _dec2$7(_class$7 = class BeanPassport extends BeanBase {
|
|
67
153
|
constructor(...args) {
|
|
68
154
|
super(...args);
|
|
69
155
|
this._authTokenAdapter = void 0;
|
|
@@ -254,12 +340,12 @@ let BeanPassport = (_dec$a = Bean(), _dec2$a = BeanInfo({
|
|
|
254
340
|
return payloadData2;
|
|
255
341
|
}
|
|
256
342
|
}
|
|
257
|
-
}) || _class$
|
|
343
|
+
}) || _class$7) || _class$7);
|
|
258
344
|
|
|
259
|
-
var _dec$
|
|
260
|
-
let BeanRoleInner = (_dec$
|
|
345
|
+
var _dec$6, _dec2$6, _class$6;
|
|
346
|
+
let BeanRoleInner = (_dec$6 = Bean(), _dec2$6 = BeanInfo({
|
|
261
347
|
module: "a-user"
|
|
262
|
-
}), _dec$
|
|
348
|
+
}), _dec$6(_class$6 = _dec2$6(_class$6 = class BeanRoleInner extends BeanBase {
|
|
263
349
|
constructor(...args) {
|
|
264
350
|
super(...args);
|
|
265
351
|
this._roleInnerAdapter = void 0;
|
|
@@ -280,12 +366,12 @@ let BeanRoleInner = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
280
366
|
findAllByUserId(userId) {
|
|
281
367
|
return this.roleInnerAdapter.findAllByUserId(userId);
|
|
282
368
|
}
|
|
283
|
-
}) || _class$
|
|
369
|
+
}) || _class$6) || _class$6);
|
|
284
370
|
|
|
285
|
-
var _dec$
|
|
286
|
-
let BeanUserInner = (_dec$
|
|
371
|
+
var _dec$5, _dec2$5, _class$5;
|
|
372
|
+
let BeanUserInner = (_dec$5 = Bean(), _dec2$5 = BeanInfo({
|
|
287
373
|
module: "a-user"
|
|
288
|
-
}), _dec$
|
|
374
|
+
}), _dec$5(_class$5 = _dec2$5(_class$5 = class BeanUserInner extends BeanBase {
|
|
289
375
|
constructor(...args) {
|
|
290
376
|
super(...args);
|
|
291
377
|
this._userInnerAdapter = void 0;
|
|
@@ -315,108 +401,22 @@ let BeanUserInner = (_dec$8 = Bean(), _dec2$8 = BeanInfo({
|
|
|
315
401
|
remove(user) {
|
|
316
402
|
return this.userInnerAdapter.remove(user);
|
|
317
403
|
}
|
|
318
|
-
}) || _class$
|
|
319
|
-
|
|
320
|
-
var _dec$7, _dec2$7, _class$7;
|
|
321
|
-
let EventCreateUserAnonymous = (_dec$7 = Event(), _dec2$7 = BeanInfo({
|
|
322
|
-
module: "a-user"
|
|
323
|
-
}), _dec$7(_class$7 = _dec2$7(_class$7 = class EventCreateUserAnonymous extends BeanEventBase {}) || _class$7) || _class$7);
|
|
324
|
-
|
|
325
|
-
var _dec$6, _dec2$6, _class$6;
|
|
326
|
-
let EventSignin = (_dec$6 = Event(), _dec2$6 = BeanInfo({
|
|
327
|
-
module: "a-user"
|
|
328
|
-
}), _dec$6(_class$6 = _dec2$6(_class$6 = class EventSignin extends BeanEventBase {}) || _class$6) || _class$6);
|
|
329
|
-
|
|
330
|
-
var _dec$5, _dec2$5, _class$5;
|
|
331
|
-
let EventSignout = (_dec$5 = Event(), _dec2$5 = BeanInfo({
|
|
332
|
-
module: "a-user"
|
|
333
|
-
}), _dec$5(_class$5 = _dec2$5(_class$5 = class EventSignout extends BeanEventBase {}) || _class$5) || _class$5);
|
|
404
|
+
}) || _class$5) || _class$5);
|
|
334
405
|
|
|
335
406
|
var _dec$4, _dec2$4, _class$4;
|
|
336
|
-
let
|
|
337
|
-
global: true,
|
|
338
|
-
public: false,
|
|
339
|
-
checkAuthToken: true
|
|
340
|
-
}), _dec2$4 = BeanInfo({
|
|
407
|
+
let EventCreateUserAnonymous = (_dec$4 = Event(), _dec2$4 = BeanInfo({
|
|
341
408
|
module: "a-user"
|
|
342
|
-
}), _dec$4(_class$4 = _dec2$4(_class$4 = class
|
|
343
|
-
async execute(options, next) {
|
|
344
|
-
// auth token
|
|
345
|
-
if (!this.bean.passport.getCurrent()) {
|
|
346
|
-
if (options.checkAuthToken) {
|
|
347
|
-
// will return undefined if no accessToken, so not check options.public
|
|
348
|
-
const [_, err] = await catchError(() => {
|
|
349
|
-
return this.bean.passport.checkAuthToken();
|
|
350
|
-
});
|
|
351
|
-
if (err && !options.public) throw err;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
// check current
|
|
355
|
-
if (!this.bean.passport.getCurrent()) {
|
|
356
|
-
await this.bean.passport.signinWithAnonymous();
|
|
357
|
-
}
|
|
358
|
-
if (!options.public && !this.bean.passport.isAuthenticated) {
|
|
359
|
-
// return false;
|
|
360
|
-
// 401 for this guard,403 for the next guards
|
|
361
|
-
return this.app.throw(401);
|
|
362
|
-
}
|
|
363
|
-
// check innerAccess
|
|
364
|
-
if (this.ctx.innerAccess) return true;
|
|
365
|
-
// next
|
|
366
|
-
return next();
|
|
367
|
-
}
|
|
368
|
-
}) || _class$4) || _class$4);
|
|
369
|
-
|
|
370
|
-
let __roleAdapter;
|
|
371
|
-
function setRoleAdapter(roleAdapter) {
|
|
372
|
-
__roleAdapter = roleAdapter;
|
|
373
|
-
}
|
|
374
|
-
function $getRoleId(role) {
|
|
375
|
-
return __roleAdapter.getRoleId(role);
|
|
376
|
-
}
|
|
377
|
-
function $getRoleName(role) {
|
|
378
|
-
return __roleAdapter.getRoleName(role);
|
|
379
|
-
}
|
|
409
|
+
}), _dec$4(_class$4 = _dec2$4(_class$4 = class EventCreateUserAnonymous extends BeanEventBase {}) || _class$4) || _class$4);
|
|
380
410
|
|
|
381
411
|
var _dec$3, _dec2$3, _class$3;
|
|
382
|
-
let
|
|
383
|
-
passWhenMatched: true
|
|
384
|
-
}), _dec2$3 = BeanInfo({
|
|
412
|
+
let EventSignin = (_dec$3 = Event(), _dec2$3 = BeanInfo({
|
|
385
413
|
module: "a-user"
|
|
386
|
-
}), _dec$3(_class$3 = _dec2$3(_class$3 = class
|
|
387
|
-
async execute(options, next) {
|
|
388
|
-
if (!options.name) return this.app.throw(403);
|
|
389
|
-
const user = this.bean.passport.getCurrentUser();
|
|
390
|
-
if (!user || $getUserAnonymous(user)) return this.app.throw(403);
|
|
391
|
-
const roles = this.bean.passport.getCurrentRoles();
|
|
392
|
-
if (!roles) return this.app.throw(403);
|
|
393
|
-
const roleNames = roles?.map(item => $getRoleName(item));
|
|
394
|
-
const optionsName = Array.isArray(options.name) ? options.name : [options.name];
|
|
395
|
-
if (!roleNames.some(roleName => optionsName.includes(roleName))) return this.app.throw(403);
|
|
396
|
-
if (options.passWhenMatched) return true;
|
|
397
|
-
// next
|
|
398
|
-
return next();
|
|
399
|
-
}
|
|
400
|
-
}) || _class$3) || _class$3);
|
|
414
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class EventSignin extends BeanEventBase {}) || _class$3) || _class$3);
|
|
401
415
|
|
|
402
416
|
var _dec$2, _dec2$2, _class$2;
|
|
403
|
-
let
|
|
404
|
-
passWhenMatched: true
|
|
405
|
-
}), _dec2$2 = BeanInfo({
|
|
417
|
+
let EventSignout = (_dec$2 = Event(), _dec2$2 = BeanInfo({
|
|
406
418
|
module: "a-user"
|
|
407
|
-
}), _dec$2(_class$2 = _dec2$2(_class$2 = class
|
|
408
|
-
async execute(options, next) {
|
|
409
|
-
if (!options.name) return this.app.throw(403);
|
|
410
|
-
const user = this.bean.passport.getCurrentUser();
|
|
411
|
-
if (!user || $getUserAnonymous(user)) return this.app.throw(403);
|
|
412
|
-
const userName = $getUserName(user);
|
|
413
|
-
const optionsName = Array.isArray(options.name) ? options.name : [options.name];
|
|
414
|
-
if (!optionsName.includes(userName)) return this.app.throw(403);
|
|
415
|
-
if (options.passWhenMatched) return true;
|
|
416
|
-
// next
|
|
417
|
-
return next();
|
|
418
|
-
}
|
|
419
|
-
}) || _class$2) || _class$2);
|
|
419
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class EventSignout extends BeanEventBase {}) || _class$2) || _class$2);
|
|
420
420
|
|
|
421
421
|
var _dec$1, _dec2$1, _class$1;
|
|
422
422
|
let MetaPrintTip = (_dec$1 = Meta(), _dec2$1 = BeanInfo({
|