我安裝了Spring Security Plugin(from here)。我非常密切地關注了博客文章here。我也完全一樣在博客中說,但即使當我試圖通過插件登錄,我得到這樣的錯誤:我無法通過Spring Security Plugin登錄
Sorry, we were not able to find a user with that username and password.
這裏是我的BootStrap.groovy
文件:
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"
}
而雅當我試過grails run-app
我可以看到我的控制檯上打印的adminUser
和adminRole
值。但是我仍然無法登錄,爲什麼?
在此先感謝。
你沒有仔細閱讀博客文章,我想你應該找自己,而不是要求每一個問題上SO的解決方案。 – 2012-01-01 15:23:31
@downvoters:爲什麼downvote? – 2012-01-01 15:29:06
哦,非常抱歉..!我在閱讀時忽略了這部分:(對不起這樣一個愚蠢的問題!) – 2012-01-01 15:35:20