抱歉,我们无法找到具有该用户名和密码的用户。 (Grails-Spring安全核心) [英] Sorry, we were not able to find a user with that username and password. (Grails-Spring Security Core)
问题描述
我是Grails新手,尝试使用Spring Security Core插件为用户分配角色。我为我的项目调用了MyProject。
在为我的模型生成控制器和视图后,在 Config.groovy
,我已经设置了必要的登录以访问/ userMyProject /:
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/ userMyProject / **':['ROLE_ADMIN']
]
<然后在 BootStrap.groovy
中自动创建一些用户和角色:
def init = {servletContext - >
def role1 = new Role();
role1.setAuthority(ROLE_ADMIN)
role1.save();
def user1 = new UserMyProject();
// ...分配名称,用户名,密码...
user1.save();
new UserMyProjectRole(userCwitter:user1,role:role1).save();
}
但是当我进入我的 感谢您的帮助。 您是否在编码密码(1.2版之前)? 编辑: 你确定用户被保存在数据库中吗?添加 I'm new to Grails and trying to use Spring Security Core plugin to assign roles to users. I called my project "MyProject". After having generated controllers and views for my models, in Then in But then when I go to my Thanks for your help. In the part: Are you encoding the password (before version 1.2)? A good reference on how to setup Spring security with Grails. Edit: Are you sure the user got saved in th DB? Add 这篇关于抱歉,我们无法找到具有该用户名和密码的用户。 (Grails-Spring安全核心)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! UserMyProjectController
页面,它正确地打开登录页面,但总是大声抱歉,我们无法找到具有该用户名和密码的用户。当我能够在我的数据库中看到它时。
// ...分配姓名,用户名,密码...
def springSecurityService
...
springSecurityService.encodePassword('password')
save(flush:true,failOnError:true)
并在数据库中检查用户是否在这里。Config.groovy
, I've set a required login in order to access /userMyProject/ :grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/userMyProject/**': ['ROLE_ADMIN']
]
BootStrap.groovy
I create automatically some users and roles :def init = { servletContext ->
def role1 = new Role();
role1.setAuthority("ROLE_ADMIN")
role1.save();
def user1 = new UserMyProject();
// ... assigning name, username, password...
user1.save();
new UserMyProjectRole(userCwitter:user1, role:role1).save();
}
UserMyProjectController
page, it correctly opens the login page but always yells Sorry, we were not able to find a user with that username and password. when I'm able to see it in my DB.// ... assigning name, username, password...
def springSecurityService
...
springSecurityService.encodePassword('password')
save(flush: true, failOnError: true)
and check in the DB if your user is here.