Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 7th, 2013  |  syntax: None  |  size: 0.73 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
  2.  
  3. class RobotController {
  4.  
  5.     def springSecurityService
  6.  
  7.     def edit() {
  8.  
  9.         if (Robot.get(params.id).usuario.username == springSecurityService.authentication.name
  10.          || SpringSecurityUtils.ifAnyGranted("ROL_ADMIN,ROL_SUPERADMIN"))              
  11.             println "editing allowed"
  12.         else
  13.             println "editing denied"
  14.  
  15.     }
  16. }
  17.        
  18. grails.plugins.springsecurity.interceptUrlMap = [
  19.     '/index.gsp': ["isAuthenticated()"],
  20.     '/robot/edit/**': ["Robot.get(params.id).usuario.username == springSecurityService.authentication.name
  21.                         || hasAnyRole('ROL_ADMIN','ROL_SUPERADMIN')"],
  22.     '/robot/**': ["isAuthenticated()"]
  23. ]
clone this paste RAW Paste Data