vona-module-a-user 5.0.30 → 5.0.32
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/index.js +9 -11
- package/dist/types/user.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BeanInfo, BeanBase, beanFullNameFromOnionName, createHash, uuidv4, BeanScopeBase } from 'vona';
|
|
2
|
-
import { catchError } from '@cabloy/utils';
|
|
2
|
+
import { catchError, isNil } from '@cabloy/utils';
|
|
3
3
|
import { Guard, Aspect } from 'vona-module-a-aspect';
|
|
4
4
|
import { Bean, Service, Scope } from 'vona-module-a-bean';
|
|
5
5
|
import { CacheRedis, BeanCacheRedisBase } from 'vona-module-a-cache';
|
|
@@ -164,6 +164,7 @@ let BeanPassport = (_dec$c = Bean(), _dec2$c = BeanInfo({
|
|
|
164
164
|
return this.ctx.state.passport?.roles;
|
|
165
165
|
}
|
|
166
166
|
async signin(passport, options) {
|
|
167
|
+
if (isNil(this.ctx.instanceName)) throw new Error('should specify instance');
|
|
167
168
|
// current
|
|
168
169
|
await this.setCurrent(passport);
|
|
169
170
|
// event
|
|
@@ -188,6 +189,7 @@ let BeanPassport = (_dec$c = Bean(), _dec2$c = BeanInfo({
|
|
|
188
189
|
await this.setCurrent(undefined);
|
|
189
190
|
}
|
|
190
191
|
async signinSystem(authName, authId, name, options) {
|
|
192
|
+
if (isNil(this.ctx.instanceName)) throw new Error('should specify instance');
|
|
191
193
|
const user = await this.bean.user.findOneByName(name ?? 'admin');
|
|
192
194
|
if (!user) return this.app.throw(401);
|
|
193
195
|
const auth = {
|
|
@@ -391,19 +393,19 @@ let BeanUser = (_dec$a = Bean(), _dec2$a = BeanInfo({
|
|
|
391
393
|
const user = await this.userAdapter.userOfProfile(profile);
|
|
392
394
|
return await this.register(user, profile.confirmed);
|
|
393
395
|
}
|
|
394
|
-
createAnonymous() {
|
|
396
|
+
async createAnonymous() {
|
|
395
397
|
return this.userAdapter.createAnonymous();
|
|
396
398
|
}
|
|
397
|
-
findOneByName(name) {
|
|
399
|
+
async findOneByName(name) {
|
|
398
400
|
return this.userAdapter.findOneByName(name);
|
|
399
401
|
}
|
|
400
|
-
findOne(user) {
|
|
402
|
+
async findOne(user) {
|
|
401
403
|
return this.userAdapter.findOne(user);
|
|
402
404
|
}
|
|
403
|
-
update(user) {
|
|
405
|
+
async update(user) {
|
|
404
406
|
return this.userAdapter.update(user);
|
|
405
407
|
}
|
|
406
|
-
remove(user) {
|
|
408
|
+
async remove(user) {
|
|
407
409
|
return this.userAdapter.remove(user);
|
|
408
410
|
}
|
|
409
411
|
}) || _class$a) || _class$a);
|
|
@@ -539,11 +541,7 @@ let MetaPrintTip = (_dec$1 = Meta(), _dec2$1 = BeanInfo({
|
|
|
539
541
|
async execute() {
|
|
540
542
|
if (!this.app.meta.isDev) return;
|
|
541
543
|
// signin
|
|
542
|
-
const jwt = await this.
|
|
543
|
-
return await this.bean.passport.signinSystem('dev', '-1');
|
|
544
|
-
}, {
|
|
545
|
-
instanceName: ''
|
|
546
|
-
});
|
|
544
|
+
const jwt = await this.bean.passport.signinSystem('dev', '-1');
|
|
547
545
|
const accessToken = jwt.accessToken;
|
|
548
546
|
return {
|
|
549
547
|
title: 'access token [admin] [dev]',
|
package/dist/types/user.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export interface IUserBase {
|
|
|
19
19
|
}
|
|
20
20
|
export interface IUserAdapter {
|
|
21
21
|
create(user: Partial<IUserBase>): Promise<IUserBase>;
|
|
22
|
-
userOfProfile(profile: IAuthUserProfile): Promise<IUserBase
|
|
23
|
-
createAnonymous(): Promise<IUserBase
|
|
22
|
+
userOfProfile(profile: IAuthUserProfile): Promise<Partial<IUserBase>>;
|
|
23
|
+
createAnonymous(): Promise<Partial<IUserBase>>;
|
|
24
24
|
findOneByName(name: string): Promise<IUserBase | undefined>;
|
|
25
25
|
findOne(user: Partial<IUserBase>): Promise<IUserBase | undefined>;
|
|
26
26
|
update(user: Partial<IUserBase>): Promise<void>;
|