File tree 2 files changed +5
-2
lines changed
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ module.exports = {
43
43
if ( sift ) req . appliedScope = sift ;
44
44
} else {
45
45
for ( const scope of req . controller . scopes ) {
46
- if ( req . user . scope . indexOf ( scope ) > - 1 ) req . appliedScope = scope ;
46
+ if ( req . user . scope && req . user . scope . indexOf ( scope ) > - 1 ) req . appliedScope = scope ;
47
47
}
48
48
49
49
}
Original file line number Diff line number Diff line change @@ -628,7 +628,9 @@ describe('[MIDDLEWARE]', function() {
628
628
var request = httpMocks . createRequest ( {
629
629
caughtScope : [ '*' , 'admin' ] ,
630
630
method : 'GET' ,
631
- user : { } ,
631
+ user : {
632
+ scope : [ 'admin' ]
633
+ } ,
632
634
controller : {
633
635
scopes : [ '*' , 'owner' , 'admin' ] ,
634
636
_rest : false ,
@@ -641,6 +643,7 @@ describe('[MIDDLEWARE]', function() {
641
643
var response = httpMocks . createResponse ( ) ;
642
644
643
645
middleware ( request , response , function ( ) {
646
+ console . log ( request . appliedScope ) ;
644
647
expect ( request ) . to . have . property ( 'appliedScope' ) ;
645
648
expect ( request . appliedScope ) . to . equal ( 'admin' ) ;
646
649
} ) ;
You can’t perform that action at this time.
0 commit comments