Final Bootstrap.groovy


/ Published in: Groovy
Save to your folder(s)



Copy this code and paste it in your HTML
  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. passwd: authenticateService.encodePassword('god')).save()
  17.  
  18. def userSlave = new User( username:'slave',
  19. userRealName:'poor slave',
  20. enabled: true,
  21. emailShow: true,
  22. passwd: authenticateService.encodePassword('slave')).save()
  23.  
  24. def secureUserEdit = new RequestMap(url: '/user/edit', configAttribute:'ROLE_ADMIN').save()
  25. def secureUserSave = new RequestMap(url: '/user/save', configAttribute:'ROLE_ADMIN').save()
  26. def secureUserCreate = new RequestMap(url: '/user/create', configAttribute:'ROLE_ADMIN').save()
  27.  
  28. def secureUserList = new RequestMap(url: '/user/list', configAttribute:'ROLE_ADMIN, ROLE_USER').save()
  29.  
  30.  
  31. //Note that here we associate users with their respective roles
  32. roleAdmin.addToPeople(userGod)
  33. roleUser.addToPeople(userGod)
  34. roleUser.addToPeople(userSlave)
  35.  
  36. }
  37. def destroy = {
  38. }
  39. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.