spring security core grails not logging in -
installed spring security core plugin did quickstart
here user domain class
package auth class user { def springsecurityservice string username string password boolean enabled boolean accountexpired boolean accountlocked boolean passwordexpired static mapping = { // password keyword in sql dialects, quote backticks // password stored 44-char base64 hashed value password column: '`password`', length: 64 } static constraints = { username blank: false, size: 1..50, unique: true password blank: false, size: 8..100 } set getauthorities() { userrole.findallbyuser(this).collect { it.role } set } def beforeinsert() { encodepassword() } def beforeupdate() { if (isdirty('password')) { encodepassword() } } protected encodepassword() { password = springsecurityservice.encodepassword(password, username) } }
and boostrap.groovy is
class bootstrap { def init = { servletcontext -> auth.user james = new auth.user(username: 'test', enabled: true, password: 'password') james.save() if (james.haserrors()) { println("he has errors") } println("we made it! ") } def destroy = { } }
but when go login, keeps saying "sorry, not able find user username , password." thoughts?
this because using salt while encoding password.
password = springsecurityservice.encodepassword(password, username)
i have no idea of salting , hence can not guide much.
but if encode password without salting code works, just remove username when encoding password, try this
password = springsecurityservice.encodepassword(password)
hope helps.
Comments
Post a Comment