File tree 1 file changed +8
-11
lines changed 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,10 @@ internals.Auth.prototype._setupRoute = function (options, path) {
125
125
options = Hoek . applyToDefaults ( this . settings . default , options ) ;
126
126
}
127
127
128
+ if ( typeof options . scope === 'string' ) {
129
+ options . scope = [ options . scope ] ;
130
+ }
131
+
128
132
Hoek . assert ( options . strategies . length , 'Route missing authentication strategy:' , path ) ;
129
133
130
134
options . mode = options . mode || 'required' ;
@@ -269,25 +273,18 @@ internals.Auth.prototype._authenticate = function (request, next) {
269
273
270
274
// Check scope
271
275
272
- var expandScope = function ( scope ) {
273
-
274
- return scope . replace ( / { ( [ ^ { } ] + ) } / g, function ( _ , context ) {
276
+ if ( config . scope ) {
277
+ var expandScope = function ( _ , context ) {
275
278
276
279
return Hoek . reach ( {
277
280
params : request . params ,
278
281
query : request . query ,
279
282
payload : request . payload
280
283
} , context ) ;
281
- } ) ;
282
- } ;
283
-
284
- if ( config . scope ) {
285
- if ( typeof config . scope === 'string' ) {
286
- config . scope = [ config . scope ] ;
287
- }
284
+ } ;
288
285
289
286
for ( var i = 0 , il = config . scope . length ; i < il ; ++ i ) {
290
- config . scope [ i ] = expandScope ( config . scope [ i ] ) ;
287
+ config . scope [ i ] = config . scope [ i ] . replace ( / { ( [ ^ { } ] + ) } / g , expandScope ) ;
291
288
}
292
289
293
290
if ( ! credentials . scope ||
You can’t perform that action at this time.
0 commit comments