Posted By

lucastex on 03/17/09


Tagged

groovy grails acegi bootstrap


Versions (?)

Final Bootstrap.groovy


 / Published in: Groovy
 

  1. class BootStrap {
  2.  
  3. def authenticateService
  4.  
  5. def init = { servletContext ->
  6.  
  7. //Adding Roles
  8. def roleAdmin = new Role(authority:'ROLE_ADMIN', description:'App admin').save()
  9. def roleUser = new Role(authority:'ROLE_USER', description:'App user').save()
  10.  
  11. //Adding Users
  12. def userGod = new User(username:'god',
  13. userRealName:'god almighty',
  14. enabled: true,
  15. emailShow: true,
  16. email: '[email protected]',
  17. passwd: authenticateService.encodePassword('god')).save()
  18.  
  19. def userSlave = new User( username:'slave',
  20. userRealName:'poor slave',
  21. enabled: true,
  22. emailShow: true,
  23. email: '[email protected]',
  24. passwd: authenticateService.encodePassword('slave')).save()
  25.  
  26. def secureUserEdit = new RequestMap(url: '/user/edit', configAttribute:'ROLE_ADMIN').save()
  27. def secureUserSave = new RequestMap(url: '/user/save', configAttribute:'ROLE_ADMIN').save()
  28. def secureUserCreate = new RequestMap(url: '/user/create', configAttribute:'ROLE_ADMIN').save()
  29.  
  30. def secureUserList = new RequestMap(url: '/user/list', configAttribute:'ROLE_ADMIN, ROLE_USER').save()
  31.  
  32.  
  33. //Note that here we associate users with their respective roles
  34. roleAdmin.addToPeople(userGod)
  35. roleUser.addToPeople(userGod)
  36. roleUser.addToPeople(userSlave)
  37.  
  38. }
  39. def destroy = {
  40. }
  41. }

Report this snippet  

You need to login to post a comment.