File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ export class CrudRoutesFactory {
83
83
if ( isUndefined ( this . options . auth . groups ) ) {
84
84
this . options . auth . groups = CrudConfigService . config . auth . groups ;
85
85
}
86
+ if ( isUndefined ( this . options . auth . classTransformOptions ) ) {
87
+ this . options . auth . classTransformOptions = CrudConfigService . config . auth . classTransformOptions ;
88
+ }
86
89
87
90
// merge query config
88
91
const query = isObjectFull ( this . options . query ) ? this . options . query : { } ;
Original file line number Diff line number Diff line change @@ -50,9 +50,14 @@ export class CrudResponseInterceptor extends CrudBaseInterceptor implements Nest
50
50
51
51
const options : ClassTransformOptions = { } ;
52
52
/* istanbul ignore else */
53
- if ( isFunction ( crudOptions . auth ?. groups ) ) {
53
+ if ( isFunction ( crudOptions . auth ?. classTransformOptions ) ) {
54
54
const userOrRequest = crudOptions . auth . property ? req [ crudOptions . auth . property ] : req ;
55
+ Object . assign ( options , crudOptions . auth . classTransformOptions ( userOrRequest ) ) ;
56
+ }
55
57
58
+ /* istanbul ignore else */
59
+ if ( isFunction ( crudOptions . auth ?. groups ) ) {
60
+ const userOrRequest = crudOptions . auth . property ? req [ crudOptions . auth . property ] : req ;
56
61
options . groups = crudOptions . auth . groups ( userOrRequest ) ;
57
62
}
58
63
Original file line number Diff line number Diff line change 1
1
import { SCondition } from '@nestjsx/crud-request/lib/types/request-query.types' ;
2
2
import { ObjectLiteral } from '@nestjsx/util' ;
3
+ import { ClassTransformOptions } from 'class-transformer' ;
3
4
4
5
export interface AuthGlobalOptions {
5
6
property ?: string ;
7
+ /** Get options for the `classToPlain` function (response) */
8
+ classTransformOptions ?: ( req : any ) => ClassTransformOptions ;
9
+ /** Get `groups` value for the `classToPlain` function options (response) */
6
10
groups ?: ( req : any ) => string [ ] ;
7
11
}
8
12
9
13
export interface AuthOptions {
10
14
property ?: string ;
15
+ /** Get options for the `classToPlain` function (response) */
16
+ classTransformOptions ?: ( req : any ) => ClassTransformOptions ;
11
17
/** Get `groups` value for the `classToPlain` function options (response) */
12
18
groups ?: ( req : any ) => string [ ] ;
13
19
filter ?: ( req : any ) => SCondition | void ;
You can’t perform that action at this time.
0 commit comments