« Return to Thread: Bootstrap issue with Acegi

Re: Bootstrap issue with Acegi

by Sailesh Ranjit :: Rate this Message:

Reply to Author | View in Thread

Hi all,
Not sure if this is a best way to save the authorities along with the user, but it works,

import org.apache.commons.codec.digest.DigestUtils as DU

class BootStrap {

    def init = { servletContext ->
       
        def md5pass = DU.md5Hex("pass")
       
        def user_god = new User(username:"god",userRealName:"god",passwd:md5pass,enabled:true,email:"email@example.com",email_show:true,description:"Desc").save()
        def user_admin = new User(username:"admin",userRealName:"admin",passwd:md5pass,enabled:true,email:"email@example.com",email_show:false,description:"Desc").save()
       
        def role_superuser = new Role(description:"Superuser",authority:"ROLE_SUPERUSER")
        role_superuser.addToPeople(user_god)
        role_superuser.save()
       
        def role_administrator = new Role(description:"Administrator",authority:"ROLE_ADMINISTRATOR")
        role_administrator.addToPeople(user_admin)
        role_administrator.addToPeople(user_god)
        role_administrator.save()
       
        new Requestmap(url:"/captcha/**",configAttribute:"ROLE_SUPERUSER").save()
        new Requestmap(url:"/register/**",configAttribute:"ROLE_ADMINISTRATOR").save()
       
        new Product(name:"XT-20",category:"Bike",type:"Fender Eliminators",description:"Fender Eliminators").save()
        new Product(name:"GT-30",category:"Car",type:"Numberplate Mount",description:"Numberplate Mount").save()
        new Product(name:"AT-90",category:"Rocket",type:"Square Steering Wheel",description:"Square Steering Wheel").save()
       
    }
    def destroy = {
    }
}

 « Return to Thread: Bootstrap issue with Acegi