|
@@ -66,19 +66,22 @@ var Router ={
|
|
|
}
|
|
|
},
|
|
|
runHandler:function(path,handlerFile,handler,method,res){
|
|
|
- if(RouterRule && RouterRule[path] && RouterRule[path]['permission'].length){
|
|
|
+ if(RouterRule && RouterRule[path] && (RouterRule[path]['permission']).length){
|
|
|
let status = handler.session.get('status');
|
|
|
- if(!new RegExp(status).exec(RouterRule[path]['permission'])){
|
|
|
- let control = (RouterRule[path]['onerror']).split(':');
|
|
|
- let way = control[0];
|
|
|
- let output = control[1];
|
|
|
- if(way=='R'){
|
|
|
- if(!output) output = '/';
|
|
|
- return handler.endRedirect(output);
|
|
|
- }
|
|
|
- if(way=='A'){
|
|
|
- if(!output) output = 'Unauthorized';
|
|
|
- return handler.endAPI(-1,output);
|
|
|
+ if((RouterRule[path]['method'] && RouterRule[path]['method'].length && new RegExp(method).exec(RouterRule[path]['method'])) || (!RouterRule[path]['method'] || RouterRule[path]['method'].length==0)){
|
|
|
+ if(!new RegExp(status).exec(RouterRule[path]['permission'])){
|
|
|
+ let control = (RouterRule[path]['onerror']).split(':');
|
|
|
+ let way = control[0];
|
|
|
+ let output = control[1];
|
|
|
+ if(way=='R'){
|
|
|
+ if(!output) output = '/';
|
|
|
+ return handler.endRedirect(output);
|
|
|
+ }
|
|
|
+ if(way=='A'){
|
|
|
+ if(!output) output = 'Unauthorized';
|
|
|
+ return handler.endAPI(-1,output);
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
}
|