views:

2055

answers:

3

Hi guys, i upgraded my grails 1.0.4 + acegi 0.4.1 project to grails 1.1 with acegi 0.5.1.

I'm able to start my application without errors, but when i want to login i get a "wrong username or password" message. Grails-shell output is:

2009-04-26 12:38:46,997 [403984690@qtp0-0] ERROR springsecurity.GrailsDaoImpl - User
[admin] has no GrantedAuthority

Maybe someone knows why I can't login? The user "admin" is created in Bootstrap.

I hope you can help me! Thanks from germany, whitenexx

+1  A: 

I ran into the exact same problem. Check to make sure when you create the user in BootStrap.groovy that you create the user first with a password and all of the fields, even if they are optional (not sure why). Then create the new Role and then add the person to the role.

One way to check if the user is getting assigned to the role is to look at the role_people table which maps users to roles.

This is my BootStrap.groovy file:

class BootStrap {
    // include this line to encode password for ACEGI
    def authenticateService 

     def init = { servletContext ->
        //create admin user
        def password = authenticateService.passwordEncoder("password") 
        def superadmin = new User(username:"admin",userRealName:"Administrator",passwd:password,enabled:true,emailShow:true,description:"admin user",email:"put email here").save()

        //create admin role
        def sudo = new Role(authority:"ROLE_ADMIN",description:"Site Administrator")
        // now add the User to the role
         sudo.addToPeople(superadmin)
        sudo.save()

        new Role(authority:"ROLE_USER",description:"User").save()

     }
     def destroy = {
     }
}
MattS
I've found my problem. I had to edit/code the passwordEncoder() or encodePassword() method by myself (with my algorithm and so on). passwordEncoder() is deprecated, please use encodePassword()!
whitenexx
A: 

I've found my problem. I had to edit/code the passwordEncoder() or encodePassword() method by myself (with my algorithm and so on). passwordEncoder() is deprecated, please use encodePassword()!

whitenexx
A: 

Thank you, i had the same prob, changed to encodePassword() , worked!!

akhilr66