File tree Expand file tree Collapse file tree 5 files changed +32
-6
lines changed
Expand file tree Collapse file tree 5 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,8 @@ module.exports = function (grunt) {
5858 '<%= config.app %>/ast/*.js' ,
5959
6060 '<%= config.app %>/SpelExpressionParser.js' ,
61- '<%= config.app %>/SpelExpressionEvaluator.js'
61+ '<%= config.app %>/SpelExpressionEvaluator.js' ,
62+ '<%= config.app %>/StandardContext.js'
6263 ] ,
6364 dest : '<%= config.dist %>/spel2js.js'
6465 }
Original file line number Diff line number Diff line change 88 context . principal = principal || { } ;
99
1010 context . hasRole = function ( role ) {
11- if ( ! context . authentication && ! context . authentication . authorities ) {
11+ var hasRole = false ;
12+
13+ if ( ! role ) {
14+ return false ;
15+ }
16+ if ( ! context . authentication && ! Array . isArray ( context . authentication . authorities ) ) {
1217 return false ;
1318 }
1419
15- return ! ! ~ context . authentication . authorities . indexOf ( role ) ;
20+ context . authentication . authorities . forEach ( function ( grantedAuthority ) {
21+ if ( grantedAuthority . authority . toLowerCase ( ) === role . toLowerCase ( ) ) {
22+ hasRole = true ;
23+ }
24+ } ) ;
25+
26+ return hasRole ;
1627 } ;
1728
1829 context . hasPermission = function ( /*variable arguments*/ ) {
2132 if ( args . length === 1 ) {
2233 return context . hasRole ( args [ 0 ] ) ;
2334 }
24- }
35+ } ;
36+
37+ return context ;
2538 }
2639
2740 exports . StandardContext = {
Original file line number Diff line number Diff line change 5252 return context [ methodName . charAt ( 3 ) . toLowerCase ( ) + methodName . substring ( 4 ) ] = compiledArgs [ 0 ] ;
5353 }
5454
55+ //size() -> length
56+ if ( methodName === 'size' && args . length === 0 ) {
57+ return context . length ;
58+ }
59+
5560 method = maybeHandleNullSafeNavigation ( context [ methodName ] ) ;
5661 if ( method ) {
5762 return method . apply ( context , compiledArgs ) ;
Original file line number Diff line number Diff line change 2121 }
2222 }
2323
24- //handle safe navigation
2524 if ( context [ propertyName ] === undefined ) {
25+ //handle safe navigation
2626 if ( nullSafeNavigation ) {
2727 return null ;
2828 }
2929
30+ //handle conversion of Java properties to JavaScript properties
31+ //this might cause problems, I'll look into alternatives
32+ if ( propertyName === 'size' ) {
33+ return context . length ;
34+ }
35+
3036 throw {
3137 name : 'NullPointerException' ,
32- message : 'Property ' + propertyName + ' does not exist.'
38+ message : 'Property \'' + propertyName + '\ ' does not exist.'
3339 } ;
3440 }
3541
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ module.exports = function (config) {
9595
9696 'src/SpelExpressionParser.js' ,
9797 'src/SpelExpressionEvaluator.js' ,
98+ '<%= config.app %>/StandardContext.js' ,
9899
99100 'test/spec/**/*.spec.js'
100101 ]
You can’t perform that action at this time.
0 commit comments