sam1132
sam1132

Reputation: 181

Grails Security Plugin

Hi i hav installed the grails secuirty plugin.
But i am not able to log in i hav set this Username and Password in Bootstrap.

import dashboard.Role
import dashboard.Username
import dashboard.UsernameRole

class BootStrap {

    def init = { servletContext ->

        def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
        def usernameRole = new Role(authority: 'ROLE_USER').save(flush: true)

        def Username = new Username(username: 'me', enabled: true, password: 'password')
             Username.save(flush: true)

        UsernameRole.create Username, adminRole, true


    }
}

Upvotes: 0

Views: 107

Answers (1)

Oliver Tynes
Oliver Tynes

Reputation: 964

First off, don't use the class name as a variable name, that is both wrong and ambigous. At least lowercase it, like def username.

Secondly, you are not saving/creating the ROLE_USER one, only the admin one.

Thirdly, what errors do you get, username not found? Things to do to debug:

  • Look in the DB to see if there is any user there.
  • Make an action in a controller that simply does render Username.findAll() to see if anything is output

Upvotes: 1

Related Questions