vona-module-test-vona 5.0.71 → 5.0.73
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IJwtToken } from 'vona-module-a-jwt';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IUser } from 'vona-module-a-user';
|
|
3
3
|
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
4
4
|
import { BeanBase } from 'vona';
|
|
5
5
|
export interface IControllerOptionsPassport extends IDecoratorControllerOptions {
|
|
6
6
|
}
|
|
7
7
|
export declare class ControllerPassport extends BeanBase {
|
|
8
|
-
echo(name: string, user:
|
|
8
|
+
echo(name: string, user: IUser): {
|
|
9
9
|
name: string;
|
|
10
|
-
user:
|
|
10
|
+
user: IUser;
|
|
11
11
|
};
|
|
12
12
|
login(name: string): Promise<IJwtToken>;
|
|
13
13
|
isAuthenticated(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -2699,7 +2699,7 @@ let ControllerPassport = (_dec$9 = Controller({
|
|
|
2699
2699
|
return Arg.param('name')(target, key, 0);
|
|
2700
2700
|
}, _dec7$8 = function (target, key) {
|
|
2701
2701
|
return Arg.user()(target, key, 1);
|
|
2702
|
-
}, _dec8$6 = Reflect.metadata("design:type", Function), _dec9$5 = Reflect.metadata("design:paramtypes", [String, typeof
|
|
2702
|
+
}, _dec8$6 = Reflect.metadata("design:type", Function), _dec9$5 = Reflect.metadata("design:paramtypes", [String, typeof IUser === "undefined" ? Object : IUser]), _dec0$5 = Web.post('login'), _dec1$5 = Api.body(v.object(DtoJwtToken)), _dec10$4 = Passport.public(), _dec11$4 = function (target, key) {
|
|
2703
2703
|
return Arg.body('name')(target, key, 0);
|
|
2704
2704
|
}, _dec12$4 = Reflect.metadata("design:type", Function), _dec13$4 = Reflect.metadata("design:paramtypes", [String]), _dec14$3 = Web.get('isAuthenticated'), _dec15$3 = Reflect.metadata("design:type", Function), _dec16$3 = Reflect.metadata("design:paramtypes", []), _dec17$3 = Web.post('refresh'), _dec18$3 = Api.body(v.object(DtoJwtToken)), _dec19$3 = Passport.public(), _dec20$3 = function (target, key) {
|
|
2705
2705
|
return Arg.body('refreshToken')(target, key, 0);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IJwtToken } from 'vona-module-a-jwt';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IUser, IUserNameRecord } from 'vona-module-a-user';
|
|
3
3
|
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
4
4
|
import assert from 'node:assert';
|
|
5
5
|
import { BeanBase } from 'vona';
|
|
@@ -15,7 +15,7 @@ export interface IControllerOptionsPassport extends IDecoratorControllerOptions
|
|
|
15
15
|
export class ControllerPassport extends BeanBase {
|
|
16
16
|
@Web.get('echo/:name')
|
|
17
17
|
@Passport.public()
|
|
18
|
-
echo(@Arg.param('name') name: string, @Arg.user() user:
|
|
18
|
+
echo(@Arg.param('name') name: string, @Arg.user() user: IUser) {
|
|
19
19
|
assert.equal(name, 'admin');
|
|
20
20
|
assert.equal(user.name, 'admin');
|
|
21
21
|
return { name, user };
|
package/test/authSimple.test.ts
CHANGED
|
@@ -16,10 +16,11 @@ describe('authSimple.test.ts', () => {
|
|
|
16
16
|
|
|
17
17
|
it('action:authSimple', async () => {
|
|
18
18
|
await app.bean.executor.mockCtx(async () => {
|
|
19
|
+
const password = app.scope('home-user').config.passwordDefault.admin;
|
|
19
20
|
// login
|
|
20
21
|
const jwt = await app.bean.auth.authenticate('a-authsimple:simple', {
|
|
21
22
|
clientName: 'default',
|
|
22
|
-
clientOptions: { username: 'admin', password
|
|
23
|
+
clientOptions: { username: 'admin', password },
|
|
23
24
|
});
|
|
24
25
|
assert.equal(!!jwt?.accessToken, true);
|
|
25
26
|
// isAuthenticated: isolate
|
|
@@ -36,7 +37,7 @@ describe('authSimple.test.ts', () => {
|
|
|
36
37
|
assert.equal(isAuthenticated, true);
|
|
37
38
|
// login again
|
|
38
39
|
const jwt2 = await app.bean.authSimple.authenticate(
|
|
39
|
-
{ username: 'admin', password
|
|
40
|
+
{ username: 'admin', password },
|
|
40
41
|
'login',
|
|
41
42
|
'default',
|
|
42
43
|
);
|