Changeset 15 for trunk/grails-app/controllers/BaseController.groovy
- Timestamp:
- Oct 21, 2009, 1:04:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/BaseController.groovy
r13 r15 1 1 import org.codehaus.groovy.grails.commons.GrailsApplication 2 2 import grails.util.GrailsUtil 3 //import org.apache.log4j.*4 3 5 4 /** … … 23 22 * @visibility public 24 23 */ 25 public def Authorization; 26 public def scaffold = false; 24 public def authorizationService; 25 26 /** 27 * @var boolean scaffolding default 28 * @visibility public 29 */ 30 def scaffold = false; 27 31 28 32 /** 29 33 * class constructor 34 * @visibility protected 30 35 * @void 31 36 */ 32 37 protected BaseController() { 33 // instantiate Authorization class 34 this.Authorization = new Authorization(); 38 // debug line for now 39 printf("instantiated %s\n",this.class.name); 40 41 // instantiate Authorization service 42 this.authorizationService = new AuthorizationService(); 35 43 36 44 // dynamically set scaffolding … … 39 47 40 48 /** 41 * Render default output to the browser, overload this in extended classes42 * @void43 */44 def index = {45 render(sprintf("default index for %s @ %s environment :: nothing to see here! :)",this.class.name,GrailsUtil.environment));46 }47 48 /**49 49 * intercept any method calls in extended classes 50 * @visibility public 50 51 * @see http://www.grails.org/Controllers+-+Interceptors 51 52 */ … … 53 54 def controller = params.controller; 54 55 def action = params.action; 55 56 56 57 // check if the user is Authorized to call this method 57 if ( Authorization.isAuthorized(controller,action)) {58 if (this.authorizationService.isAuthorized(controller,action)) { 58 59 // user is not authorized to use this functionality 59 printf("authorized call to action: %s->%s(...)\n", controller,action);60 printf("authorized call to action: %s->%s(...)\n",this.class.name,action); 60 61 } else { 61 // user is not authorized to use this functionality62 printf("!! unauthorized call to action: %s-->%s(...)\n", controller,action);62 // user is not authorized to use this controller + method 63 printf("!! unauthorized call to action: %s-->%s(...)\n",this.class.name,action); 63 64 64 65 // redirect to error page … … 67 68 } 68 69 } 69 70 /**71 * after interception72 * @param object model73 * @param object modelAndView74 * @see http://www.grails.org/Controllers+-+Interceptors75 */76 def afterInterceptor = {77 // nothing here yet78 }79 70 }
Note: See TracChangeset
for help on using the changeset viewer.