I installed Spring Security Plugin(from here). I followed the blog post very closely here. I did exactly the same as said in that blog post, but even though when I tried to log in through the plugin, I’m getting an error like this:
Sorry, we were not able to find a user with that username and password.
Here is my BootStrap.groovy file :
def springSecurityService
def init = {
def userRole = SecRole.findByAuthority('ROLE_USER') ?: new SecRole(authority: 'ROLE_USER').save(failOnError: true)
def adminRole = SecRole.findByAuthority('ROLE_USER') ?: new SecRole(authority: 'ROLE_USER').save(failOnError: true)
def adminUser = SecUser.findByUsername('antoaravinth') ?: new SecUser(
username: 'antoaravinth',
password: springSecurityService.encodePassword('secret'),
enabled: true).save()
if (!adminUser.authorities.contains(adminRole)) {
SecUserSecRole.create adminUser, adminRole
}
println "adminUser is $adminUser"
println "adminRole is $adminRole"
}
And ya when I tried grails run-app I can see both the adminUser and adminRole value printed on my console. But still I couldn’t able to log in. Why?
Thanks in advance.
The post has this update which describes why your logins fail: