« Return to Thread: Bootstrap issue with Acegi

Re: Bootstrap issue with Acegi

by Sailesh Ranjit :: Rate this Message:

Reply to Author | View in Thread

Realized that it works if you put full set of attributes even if they are not in constraints, not sure what is the reason behind this is. So, the user will save if we change User(...).save() as follows, the next thing I am trying to find out is how to save the authorities along with user, at the moment it does add the user but with no authority.

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

class BootStrap {

    def init = { servletContext ->
       
        def md5pass = DU.md5Hex("pass")
       
        new User(username:"god",userRealName:"god",passwd:md5pass,enabled:true,email:"email@example.com",email_show:true,description:"Desc").save()
        new User(username:"admin",userRealName:"admin",passwd:md5pass,enabled:true,email:"email@example.com",email_show:true,description:"Desc").save()
       
        new Role(username:"god",description:"Superuser",authority:"ROLE_SUPERUSER").save()
        new Role(username:"admin",description:"Administrator",authority:"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