vona-module-a-user 5.0.20 → 5.0.22
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 +11 -0
- package/dist/bean/bean.passport.d.ts +1 -0
- package/dist/bean/bean.roleInner.d.ts +1 -1
- package/dist/bean/bean.userInner.d.ts +3 -1
- package/dist/bean/event.activate.d.ts +6 -0
- package/dist/bean/guard.passport.d.ts +1 -0
- package/dist/config/config.d.ts +3 -0
- package/dist/index.js +98 -46
- package/dist/lib/auth.d.ts +1 -1
- package/dist/lib/passport.d.ts +3 -3
- package/dist/lib/role.d.ts +1 -1
- package/dist/lib/user.d.ts +4 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/role.d.ts +1 -1
- package/dist/types/user.d.ts +7 -2
- package/package.json +1 -1
|
@@ -113,6 +113,7 @@ declare module 'vona' {
|
|
|
113
113
|
}
|
|
114
114
|
/** service: end */
|
|
115
115
|
/** event: begin */
|
|
116
|
+
export * from '../bean/event.activate.ts';
|
|
116
117
|
export * from '../bean/event.createUserAnonymous.ts';
|
|
117
118
|
export * from '../bean/event.signin.ts';
|
|
118
119
|
export * from '../bean/event.signout.ts';
|
|
@@ -120,6 +121,12 @@ import 'vona';
|
|
|
120
121
|
declare module 'vona' {
|
|
121
122
|
}
|
|
122
123
|
declare module 'vona-module-a-user' {
|
|
124
|
+
interface EventActivate {
|
|
125
|
+
}
|
|
126
|
+
interface EventActivate {
|
|
127
|
+
get $beanFullName(): 'a-user.event.activate';
|
|
128
|
+
get $onionName(): 'a-user:activate';
|
|
129
|
+
}
|
|
123
130
|
interface EventCreateUserAnonymous {
|
|
124
131
|
}
|
|
125
132
|
interface EventCreateUserAnonymous {
|
|
@@ -141,22 +148,26 @@ declare module 'vona-module-a-user' {
|
|
|
141
148
|
}
|
|
142
149
|
/** event: end */
|
|
143
150
|
/** event: begin */
|
|
151
|
+
import type { EventActivate } from '../bean/event.activate.ts';
|
|
144
152
|
import type { EventCreateUserAnonymous } from '../bean/event.createUserAnonymous.ts';
|
|
145
153
|
import type { EventSignin } from '../bean/event.signin.ts';
|
|
146
154
|
import type { EventSignout } from '../bean/event.signout.ts';
|
|
147
155
|
export interface IModuleEvent {
|
|
156
|
+
'activate': EventActivate;
|
|
148
157
|
'createUserAnonymous': EventCreateUserAnonymous;
|
|
149
158
|
'signin': EventSignin;
|
|
150
159
|
'signout': EventSignout;
|
|
151
160
|
}
|
|
152
161
|
/** event: end */
|
|
153
162
|
/** event: begin */
|
|
163
|
+
import type { TypeEventActivateData, TypeEventActivateResult } from '../bean/event.activate.ts';
|
|
154
164
|
import type { TypeEventCreateUserAnonymousData, TypeEventCreateUserAnonymousResult } from '../bean/event.createUserAnonymous.ts';
|
|
155
165
|
import type { TypeEventSigninData, TypeEventSigninResult } from '../bean/event.signin.ts';
|
|
156
166
|
import type { TypeEventSignoutData, TypeEventSignoutResult } from '../bean/event.signout.ts';
|
|
157
167
|
import type { EventOn } from 'vona-module-a-event';
|
|
158
168
|
declare module 'vona-module-a-event' {
|
|
159
169
|
interface IEventRecord {
|
|
170
|
+
'a-user:activate': EventOn<TypeEventActivateData, TypeEventActivateResult>;
|
|
160
171
|
'a-user:createUserAnonymous': EventOn<TypeEventCreateUserAnonymousData, TypeEventCreateUserAnonymousResult>;
|
|
161
172
|
'a-user:signin': EventOn<TypeEventSigninData, TypeEventSigninResult>;
|
|
162
173
|
'a-user:signout': EventOn<TypeEventSignoutData, TypeEventSignoutResult>;
|
|
@@ -11,6 +11,7 @@ export declare class BeanPassport extends BeanBase {
|
|
|
11
11
|
private get authTokenAdapter();
|
|
12
12
|
private get passportAdapter();
|
|
13
13
|
get isAuthenticated(): boolean;
|
|
14
|
+
get isActivated(): boolean;
|
|
14
15
|
isAdmin(): Promise<boolean>;
|
|
15
16
|
setCurrent(passport: IPassportBase | undefined): Promise<void>;
|
|
16
17
|
getCurrent(): IPassportBase | undefined;
|
|
@@ -4,7 +4,9 @@ import { BeanBase } from 'vona';
|
|
|
4
4
|
export declare class BeanUserInner extends BeanBase {
|
|
5
5
|
private _userInnerAdapter;
|
|
6
6
|
private get userInnerAdapter();
|
|
7
|
-
|
|
7
|
+
activate(user: IUserBase): Promise<void>;
|
|
8
|
+
register(user: Partial<IUserBase>, autoActivate?: boolean): Promise<IUserBase>;
|
|
9
|
+
registerByProfile(profile: IAuthUserProfile): Promise<IUserBase>;
|
|
8
10
|
createAnonymous(): Promise<IUserBase>;
|
|
9
11
|
findOneByName(name: string): Promise<IUserBase | undefined>;
|
|
10
12
|
findOne(user: Partial<IUserBase>): Promise<IUserBase | undefined>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IUserBase } from '../types/user.ts';
|
|
2
|
+
import { BeanEventBase } from 'vona-module-a-event';
|
|
3
|
+
export type TypeEventActivateData = IUserBase;
|
|
4
|
+
export type TypeEventActivateResult = void;
|
|
5
|
+
export declare class EventActivate extends BeanEventBase<TypeEventActivateData, TypeEventActivateResult> {
|
|
6
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { IDecoratorGuardOptionsGlobal, IGuardExecute } from 'vona-module-a-
|
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
4
|
export interface IGuardOptionsPassport extends IDecoratorGuardOptionsGlobal {
|
|
5
5
|
public: boolean;
|
|
6
|
+
activated?: boolean;
|
|
6
7
|
checkAuthToken: boolean;
|
|
7
8
|
}
|
|
8
9
|
export declare class GuardPassport extends BeanBase implements IGuardExecute {
|
package/dist/config/config.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import type { VonaApplication } from 'vona';
|
|
|
2
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
|
+
user: {
|
|
6
|
+
autoActivate: boolean;
|
|
7
|
+
};
|
|
5
8
|
passport: {
|
|
6
9
|
refreshAuthToken: TypeAuthToken;
|
|
7
10
|
};
|
package/dist/index.js
CHANGED
|
@@ -5,14 +5,15 @@ import { Bean, Service, Scope } from 'vona-module-a-bean';
|
|
|
5
5
|
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
6
6
|
import { Meta } from 'vona-module-a-meta';
|
|
7
7
|
|
|
8
|
-
var _dec$
|
|
9
|
-
let GuardPassport = (_dec$
|
|
8
|
+
var _dec$e, _dec2$e, _class$e;
|
|
9
|
+
let GuardPassport = (_dec$e = Guard({
|
|
10
10
|
global: true,
|
|
11
11
|
public: false,
|
|
12
|
+
activated: true,
|
|
12
13
|
checkAuthToken: true
|
|
13
|
-
}), _dec2$
|
|
14
|
+
}), _dec2$e = BeanInfo({
|
|
14
15
|
module: "a-user"
|
|
15
|
-
}), _dec$
|
|
16
|
+
}), _dec$e(_class$e = _dec2$e(_class$e = class GuardPassport extends BeanBase {
|
|
16
17
|
async execute(options, next) {
|
|
17
18
|
// auth token
|
|
18
19
|
if (!this.bean.passport.getCurrent()) {
|
|
@@ -30,15 +31,23 @@ let GuardPassport = (_dec$d = Guard({
|
|
|
30
31
|
}
|
|
31
32
|
if (!options.public && !this.bean.passport.isAuthenticated) {
|
|
32
33
|
// return false;
|
|
33
|
-
// 401 for this guard,403 for the next guards
|
|
34
|
+
// 401 for this guard, 403 for the next guards
|
|
34
35
|
return this.app.throw(401);
|
|
35
36
|
}
|
|
37
|
+
if (this.bean.passport.isAuthenticated) {
|
|
38
|
+
if (options.activated === true && !this.bean.passport.isActivated) {
|
|
39
|
+
return this.app.throw(403);
|
|
40
|
+
}
|
|
41
|
+
if (options.activated === false && this.bean.passport.isActivated) {
|
|
42
|
+
return this.app.throw(403);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
36
45
|
// check innerAccess
|
|
37
46
|
if (this.ctx.innerAccess) return true;
|
|
38
47
|
// next
|
|
39
48
|
return next();
|
|
40
49
|
}
|
|
41
|
-
}) || _class$
|
|
50
|
+
}) || _class$e) || _class$e);
|
|
42
51
|
|
|
43
52
|
let __roleAdapter;
|
|
44
53
|
function setRoleAdapter(roleAdapter) {
|
|
@@ -64,6 +73,15 @@ function $getUserName(user) {
|
|
|
64
73
|
function $getUserAvatar(user) {
|
|
65
74
|
return __userAdapter.getUserAvatar(user);
|
|
66
75
|
}
|
|
76
|
+
function $getUserEmail(user) {
|
|
77
|
+
return __userAdapter.getUserEmail(user);
|
|
78
|
+
}
|
|
79
|
+
function $getUserMobile(user) {
|
|
80
|
+
return __userAdapter.getUserMobile(user);
|
|
81
|
+
}
|
|
82
|
+
function $getUserActivated(user) {
|
|
83
|
+
return __userAdapter.getUserActivated(user);
|
|
84
|
+
}
|
|
67
85
|
function $getUserLocale(user) {
|
|
68
86
|
return __userAdapter.getUserLocale(user);
|
|
69
87
|
}
|
|
@@ -74,12 +92,12 @@ function $getUserIdSystem(_userName, userId) {
|
|
|
74
92
|
return userId;
|
|
75
93
|
}
|
|
76
94
|
|
|
77
|
-
var _dec$
|
|
78
|
-
let GuardRoleName = (_dec$
|
|
95
|
+
var _dec$d, _dec2$d, _class$d;
|
|
96
|
+
let GuardRoleName = (_dec$d = Guard({
|
|
79
97
|
passWhenMatched: true
|
|
80
|
-
}), _dec2$
|
|
98
|
+
}), _dec2$d = BeanInfo({
|
|
81
99
|
module: "a-user"
|
|
82
|
-
}), _dec$
|
|
100
|
+
}), _dec$d(_class$d = _dec2$d(_class$d = class GuardRoleName extends BeanBase {
|
|
83
101
|
async execute(options, next) {
|
|
84
102
|
if (!options.name) return this.app.throw(403);
|
|
85
103
|
const user = this.bean.passport.getCurrentUser();
|
|
@@ -93,14 +111,14 @@ let GuardRoleName = (_dec$c = Guard({
|
|
|
93
111
|
// next
|
|
94
112
|
return next();
|
|
95
113
|
}
|
|
96
|
-
}) || _class$
|
|
114
|
+
}) || _class$d) || _class$d);
|
|
97
115
|
|
|
98
|
-
var _dec$
|
|
99
|
-
let GuardUserName = (_dec$
|
|
116
|
+
var _dec$c, _dec2$c, _class$c;
|
|
117
|
+
let GuardUserName = (_dec$c = Guard({
|
|
100
118
|
passWhenMatched: true
|
|
101
|
-
}), _dec2$
|
|
119
|
+
}), _dec2$c = BeanInfo({
|
|
102
120
|
module: "a-user"
|
|
103
|
-
}), _dec$
|
|
121
|
+
}), _dec$c(_class$c = _dec2$c(_class$c = class GuardUserName extends BeanBase {
|
|
104
122
|
async execute(options, next) {
|
|
105
123
|
if (!options.name) return this.app.throw(403);
|
|
106
124
|
const user = this.bean.passport.getCurrentUser();
|
|
@@ -112,12 +130,12 @@ let GuardUserName = (_dec$b = Guard({
|
|
|
112
130
|
// next
|
|
113
131
|
return next();
|
|
114
132
|
}
|
|
115
|
-
}) || _class$
|
|
133
|
+
}) || _class$c) || _class$c);
|
|
116
134
|
|
|
117
|
-
var _dec$
|
|
118
|
-
let BeanAuthInner = (_dec$
|
|
135
|
+
var _dec$b, _dec2$b, _class$b;
|
|
136
|
+
let BeanAuthInner = (_dec$b = Bean(), _dec2$b = BeanInfo({
|
|
119
137
|
module: "a-user"
|
|
120
|
-
}), _dec$
|
|
138
|
+
}), _dec$b(_class$b = _dec2$b(_class$b = class BeanAuthInner extends BeanBase {
|
|
121
139
|
constructor(...args) {
|
|
122
140
|
super(...args);
|
|
123
141
|
this._authInnerAdapter = void 0;
|
|
@@ -133,7 +151,7 @@ let BeanAuthInner = (_dec$a = Bean(), _dec2$a = BeanInfo({
|
|
|
133
151
|
if (String(auth.id).charAt(0) === '-') return auth;
|
|
134
152
|
return await this.authInnerAdapter.findOne(auth);
|
|
135
153
|
}
|
|
136
|
-
}) || _class$
|
|
154
|
+
}) || _class$b) || _class$b);
|
|
137
155
|
|
|
138
156
|
let __authAdapter;
|
|
139
157
|
function setAuthAdapter(authAdapter) {
|
|
@@ -146,10 +164,10 @@ function $getAuthIdSystem(_authName, authId) {
|
|
|
146
164
|
return authId;
|
|
147
165
|
}
|
|
148
166
|
|
|
149
|
-
var _dec$
|
|
150
|
-
let BeanPassport = (_dec$
|
|
167
|
+
var _dec$a, _dec2$a, _class$a;
|
|
168
|
+
let BeanPassport = (_dec$a = Bean(), _dec2$a = BeanInfo({
|
|
151
169
|
module: "a-user"
|
|
152
|
-
}), _dec$
|
|
170
|
+
}), _dec$a(_class$a = _dec2$a(_class$a = class BeanPassport extends BeanBase {
|
|
153
171
|
constructor(...args) {
|
|
154
172
|
super(...args);
|
|
155
173
|
this._authTokenAdapter = void 0;
|
|
@@ -174,6 +192,10 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
174
192
|
const user = this.getCurrentUser();
|
|
175
193
|
return !!user && !$getUserAnonymous(user);
|
|
176
194
|
}
|
|
195
|
+
get isActivated() {
|
|
196
|
+
const user = this.getCurrentUser();
|
|
197
|
+
return !!user && $getUserActivated(user);
|
|
198
|
+
}
|
|
177
199
|
async isAdmin() {
|
|
178
200
|
const passport = this.getCurrent();
|
|
179
201
|
return await this.passportAdapter.isAdmin(passport);
|
|
@@ -351,12 +373,12 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
|
351
373
|
return payloadData2;
|
|
352
374
|
}
|
|
353
375
|
}
|
|
354
|
-
}) || _class$
|
|
376
|
+
}) || _class$a) || _class$a);
|
|
355
377
|
|
|
356
|
-
var _dec$
|
|
357
|
-
let BeanRoleInner = (_dec$
|
|
378
|
+
var _dec$9, _dec2$9, _class$9;
|
|
379
|
+
let BeanRoleInner = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
|
|
358
380
|
module: "a-user"
|
|
359
|
-
}), _dec$
|
|
381
|
+
}), _dec$9(_class$9 = _dec2$9(_class$9 = class BeanRoleInner extends BeanBase {
|
|
360
382
|
constructor(...args) {
|
|
361
383
|
super(...args);
|
|
362
384
|
this._roleInnerAdapter = void 0;
|
|
@@ -377,12 +399,12 @@ let BeanRoleInner = (_dec$8 = Bean(), _dec2$8 = BeanInfo({
|
|
|
377
399
|
findAllByUserId(userId) {
|
|
378
400
|
return this.roleInnerAdapter.findAllByUserId(userId);
|
|
379
401
|
}
|
|
380
|
-
}) || _class$
|
|
402
|
+
}) || _class$9) || _class$9);
|
|
381
403
|
|
|
382
|
-
var _dec$
|
|
383
|
-
let BeanUserInner = (_dec$
|
|
404
|
+
var _dec$8, _dec2$8, _class$8;
|
|
405
|
+
let BeanUserInner = (_dec$8 = Bean(), _dec2$8 = BeanInfo({
|
|
384
406
|
module: "a-user"
|
|
385
|
-
}), _dec$
|
|
407
|
+
}), _dec$8(_class$8 = _dec2$8(_class$8 = class BeanUserInner extends BeanBase {
|
|
386
408
|
constructor(...args) {
|
|
387
409
|
super(...args);
|
|
388
410
|
this._userInnerAdapter = void 0;
|
|
@@ -394,8 +416,23 @@ let BeanUserInner = (_dec$7 = Bean(), _dec2$7 = BeanInfo({
|
|
|
394
416
|
}
|
|
395
417
|
return this._userInnerAdapter;
|
|
396
418
|
}
|
|
397
|
-
|
|
398
|
-
|
|
419
|
+
async activate(user) {
|
|
420
|
+
await this.scope.event.activate.emit(user, async () => {
|
|
421
|
+
await this.userInnerAdapter.setActivated(user.id, true);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
async register(user, autoActivate) {
|
|
425
|
+
// config.user.autoActivate > autoActivate
|
|
426
|
+
autoActivate = this.scope.config.user.autoActivate ? true : autoActivate;
|
|
427
|
+
const userNew = await this.userInnerAdapter.create(user);
|
|
428
|
+
if (autoActivate) {
|
|
429
|
+
await this.activate(userNew);
|
|
430
|
+
}
|
|
431
|
+
return userNew;
|
|
432
|
+
}
|
|
433
|
+
async registerByProfile(profile) {
|
|
434
|
+
const user = await this.userInnerAdapter.userOfProfile(profile);
|
|
435
|
+
return await this.register(user, profile.confirmed);
|
|
399
436
|
}
|
|
400
437
|
createAnonymous() {
|
|
401
438
|
return this.userInnerAdapter.createAnonymous();
|
|
@@ -412,12 +449,12 @@ let BeanUserInner = (_dec$7 = Bean(), _dec2$7 = BeanInfo({
|
|
|
412
449
|
remove(user) {
|
|
413
450
|
return this.userInnerAdapter.remove(user);
|
|
414
451
|
}
|
|
415
|
-
}) || _class$
|
|
452
|
+
}) || _class$8) || _class$8);
|
|
416
453
|
|
|
417
|
-
var _dec$
|
|
418
|
-
let ServiceAuthTokenAdapter = (_dec$
|
|
454
|
+
var _dec$7, _dec2$7, _class$7;
|
|
455
|
+
let ServiceAuthTokenAdapter = (_dec$7 = Service(), _dec2$7 = BeanInfo({
|
|
419
456
|
module: "a-user"
|
|
420
|
-
}), _dec$
|
|
457
|
+
}), _dec$7(_class$7 = _dec2$7(_class$7 = class ServiceAuthTokenAdapter extends BeanBase {
|
|
421
458
|
async create(payloadData) {
|
|
422
459
|
const authIdStr = this._getAuthId(payloadData)?.toString();
|
|
423
460
|
const token = authIdStr === '-1' ? createHash(authIdStr) : uuidv4();
|
|
@@ -445,12 +482,12 @@ let ServiceAuthTokenAdapter = (_dec$6 = Service(), _dec2$6 = BeanInfo({
|
|
|
445
482
|
_getAuthId(payloadData) {
|
|
446
483
|
return payloadData[this.scope.config.payloadData.fields.authId];
|
|
447
484
|
}
|
|
448
|
-
}) || _class$
|
|
485
|
+
}) || _class$7) || _class$7);
|
|
449
486
|
|
|
450
|
-
var _dec$
|
|
451
|
-
let ServiceRedisToken = (_dec$
|
|
487
|
+
var _dec$6, _dec2$6, _class$6;
|
|
488
|
+
let ServiceRedisToken = (_dec$6 = Service(), _dec2$6 = BeanInfo({
|
|
452
489
|
module: "a-user"
|
|
453
|
-
}), _dec$
|
|
490
|
+
}), _dec$6(_class$6 = _dec2$6(_class$6 = class ServiceRedisToken extends BeanBase {
|
|
454
491
|
get redisAuth() {
|
|
455
492
|
return this.bean.redis.get('auth');
|
|
456
493
|
}
|
|
@@ -510,7 +547,12 @@ let ServiceRedisToken = (_dec$5 = Service(), _dec2$5 = BeanInfo({
|
|
|
510
547
|
_getUserId(payloadData) {
|
|
511
548
|
return payloadData[this.scope.config.payloadData.fields.userId];
|
|
512
549
|
}
|
|
513
|
-
}) || _class$
|
|
550
|
+
}) || _class$6) || _class$6);
|
|
551
|
+
|
|
552
|
+
var _dec$5, _dec2$5, _class$5;
|
|
553
|
+
let EventActivate = (_dec$5 = Event(), _dec2$5 = BeanInfo({
|
|
554
|
+
module: "a-user"
|
|
555
|
+
}), _dec$5(_class$5 = _dec2$5(_class$5 = class EventActivate extends BeanEventBase {}) || _class$5) || _class$5);
|
|
514
556
|
|
|
515
557
|
var _dec$4, _dec2$4, _class$4;
|
|
516
558
|
let EventCreateUserAnonymous = (_dec$4 = Event(), _dec2$4 = BeanInfo({
|
|
@@ -532,7 +574,7 @@ let MetaPrintTip = (_dec$1 = Meta(), _dec2$1 = BeanInfo({
|
|
|
532
574
|
module: "a-user"
|
|
533
575
|
}), _dec$1(_class$1 = _dec2$1(_class$1 = class MetaPrintTip extends BeanBase {
|
|
534
576
|
async execute() {
|
|
535
|
-
if (!this.app.meta.
|
|
577
|
+
if (!this.app.meta.isDev) return;
|
|
536
578
|
// signin
|
|
537
579
|
const jwt = await this.app.bean.executor.newCtx(async () => {
|
|
538
580
|
return await this.bean.passport.signinSystem('dev', '-1');
|
|
@@ -549,6 +591,9 @@ let MetaPrintTip = (_dec$1 = Meta(), _dec2$1 = BeanInfo({
|
|
|
549
591
|
|
|
550
592
|
function config(_app) {
|
|
551
593
|
return {
|
|
594
|
+
user: {
|
|
595
|
+
autoActivate: false
|
|
596
|
+
},
|
|
552
597
|
passport: {
|
|
553
598
|
refreshAuthToken: 'recreate'
|
|
554
599
|
},
|
|
@@ -579,12 +624,18 @@ let ScopeModuleAUser = (_dec = Scope(), _dec2 = BeanInfo({
|
|
|
579
624
|
|
|
580
625
|
/** scope: end */
|
|
581
626
|
|
|
582
|
-
function Public(
|
|
583
|
-
const _public = options?.public === undefined ? true : options.public;
|
|
627
|
+
function Public(_public = true) {
|
|
584
628
|
return Aspect.guardGlobal('a-user:passport', {
|
|
585
629
|
public: _public
|
|
586
630
|
});
|
|
587
631
|
}
|
|
632
|
+
|
|
633
|
+
// true/false/undefined
|
|
634
|
+
function Activated(activated) {
|
|
635
|
+
return Aspect.guardGlobal('a-user:passport', {
|
|
636
|
+
activated
|
|
637
|
+
});
|
|
638
|
+
}
|
|
588
639
|
function UserName(options) {
|
|
589
640
|
return Aspect.guard('a-user:userName', options);
|
|
590
641
|
}
|
|
@@ -598,9 +649,10 @@ function Admin(options) {
|
|
|
598
649
|
}
|
|
599
650
|
const Passport = {
|
|
600
651
|
public: Public,
|
|
652
|
+
activated: Activated,
|
|
601
653
|
userName: UserName,
|
|
602
654
|
roleName: RoleName,
|
|
603
655
|
admin: Admin
|
|
604
656
|
};
|
|
605
657
|
|
|
606
|
-
export { $getAuthId, $getAuthIdSystem, $getRoleId, $getRoleName, $getUserAnonymous, $getUserAvatar, $getUserId, $getUserIdSystem, $getUserLocale, $getUserName, BeanAuthInner, BeanPassport, BeanRoleInner, BeanUserInner, EventCreateUserAnonymous, EventSignin, EventSignout, GuardPassport, GuardRoleName, GuardUserName, MetaPrintTip, Passport, ScopeModuleAUser, ServiceAuthTokenAdapter, ServiceRedisToken, config, setAuthAdapter, setRoleAdapter, setUserAdapter };
|
|
658
|
+
export { $getAuthId, $getAuthIdSystem, $getRoleId, $getRoleName, $getUserActivated, $getUserAnonymous, $getUserAvatar, $getUserEmail, $getUserId, $getUserIdSystem, $getUserLocale, $getUserMobile, $getUserName, BeanAuthInner, BeanPassport, BeanRoleInner, BeanUserInner, EventActivate, EventCreateUserAnonymous, EventSignin, EventSignout, GuardPassport, GuardRoleName, GuardUserName, MetaPrintTip, Passport, ScopeModuleAUser, ServiceAuthTokenAdapter, ServiceRedisToken, config, setAuthAdapter, setRoleAdapter, setUserAdapter };
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from '
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
2
|
import type { IAuthAdapter, IAuthBase, IAuthIdRecord } from '../types/auth.ts';
|
|
3
3
|
export declare function setAuthAdapter(authAdapter: IAuthAdapter): void;
|
|
4
4
|
export declare function $getAuthId(user: IAuthBase): TableIdentity;
|
package/dist/lib/passport.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { TypeUseOnionOmitOptionsGlobal } from 'vona-module-a-onion';
|
|
2
|
-
import type { IGuardOptionsPassport } from '../bean/guard.passport.ts';
|
|
3
1
|
import type { IGuardOptionsRoleName } from '../bean/guard.roleName.ts';
|
|
4
2
|
import type { IGuardOptionsUserName } from '../bean/guard.userName.ts';
|
|
5
|
-
declare function Public(
|
|
3
|
+
declare function Public(_public?: boolean): ClassDecorator & MethodDecorator;
|
|
4
|
+
declare function Activated(activated?: boolean): ClassDecorator & MethodDecorator;
|
|
6
5
|
declare function UserName(options?: Partial<IGuardOptionsUserName>): ClassDecorator & MethodDecorator;
|
|
7
6
|
declare function RoleName(options?: Partial<IGuardOptionsRoleName>): ClassDecorator & MethodDecorator;
|
|
8
7
|
declare function Admin(options?: Partial<Omit<IGuardOptionsRoleName, 'name'>>): ClassDecorator & MethodDecorator;
|
|
9
8
|
export interface IDecoratorGroupPassport {
|
|
10
9
|
public: typeof Public;
|
|
10
|
+
activated: typeof Activated;
|
|
11
11
|
userName: typeof UserName;
|
|
12
12
|
roleName: typeof RoleName;
|
|
13
13
|
admin: typeof Admin;
|
package/dist/lib/role.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from '
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
2
|
import type { IRoleAdapter, IRoleBase } from '../types/role.ts';
|
|
3
3
|
export declare function setRoleAdapter(roleAdapter: IRoleAdapter): void;
|
|
4
4
|
export declare function $getRoleId(role: IRoleBase): TableIdentity;
|
package/dist/lib/user.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { ILocaleInfos } from 'vona';
|
|
2
|
-
import type { TableIdentity } from 'vona-module-a-orm';
|
|
3
3
|
import type { IUserAdapter, IUserBase, IUserIdRecord } from '../types/user.ts';
|
|
4
4
|
export declare function setUserAdapter(userAdapter: IUserAdapter): void;
|
|
5
5
|
export declare function $getUserId(user: IUserBase): TableIdentity;
|
|
6
6
|
export declare function $getUserName(user: IUserBase): string;
|
|
7
7
|
export declare function $getUserAvatar(user: IUserBase): string | undefined;
|
|
8
|
+
export declare function $getUserEmail(user: IUserBase): string | undefined;
|
|
9
|
+
export declare function $getUserMobile(user: IUserBase): string | undefined;
|
|
10
|
+
export declare function $getUserActivated(user: IUserBase): boolean;
|
|
8
11
|
export declare function $getUserLocale(user: IUserBase): keyof ILocaleInfos | undefined;
|
|
9
12
|
export declare function $getUserAnonymous(user: IUserBase): boolean;
|
|
10
13
|
export declare function $getUserIdSystem<K extends keyof IUserIdRecord>(_userName: IUserIdRecord[K], userId: K): TableIdentity;
|
package/dist/types/auth.d.ts
CHANGED
package/dist/types/role.d.ts
CHANGED
package/dist/types/user.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { ILocaleInfos } from 'vona';
|
|
2
|
-
import type { TableIdentity } from 'vona-module-a-orm';
|
|
3
3
|
import type { IAuthUserProfile } from './authProfile.ts';
|
|
4
4
|
export interface IUserNameRecord {
|
|
5
5
|
admin: never;
|
|
@@ -14,14 +14,19 @@ export interface IUserAdapter {
|
|
|
14
14
|
getUserId(user: IUserBase): TableIdentity;
|
|
15
15
|
getUserName(user: IUserBase): string;
|
|
16
16
|
getUserAvatar(user: IUserBase): string | undefined;
|
|
17
|
+
getUserEmail(user: IUserBase): string | undefined;
|
|
18
|
+
getUserMobile(user: IUserBase): string | undefined;
|
|
19
|
+
getUserActivated(user: IUserBase): boolean;
|
|
17
20
|
getUserLocale(user: IUserBase): keyof ILocaleInfos | undefined;
|
|
18
21
|
getUserAnonymous(user: IUserBase): boolean;
|
|
19
22
|
}
|
|
20
23
|
export interface IUserInnerAdapter {
|
|
21
|
-
|
|
24
|
+
create(user: Partial<IUserBase>): Promise<IUserBase>;
|
|
25
|
+
userOfProfile(profile: IAuthUserProfile): Promise<IUserBase>;
|
|
22
26
|
createAnonymous(): Promise<IUserBase>;
|
|
23
27
|
findOneByName(name: string): Promise<IUserBase | undefined>;
|
|
24
28
|
findOne(user: Partial<IUserBase>): Promise<IUserBase | undefined>;
|
|
25
29
|
update(user: Partial<IUserBase>): Promise<void>;
|
|
26
30
|
remove(user: Partial<IUserBase>): Promise<void>;
|
|
31
|
+
setActivated(id: TableIdentity, activated: boolean): Promise<void>;
|
|
27
32
|
}
|