Note that there are some explanatory texts on larger screens.

plurals
  1. POWith specified username getting 'Sorry, we were not able to find a user with that username and password.' message when logging int
    text
    copied!<p>I have installed the grails Spring-Security plugin:</p> <pre><code>plugins { compile ':spring-security-core:2.0-RC2' } </code></pre> <p>Then I used the grails s2-quickstart com.jane Person Role command to create the needed domain classes.</p> <p>As I have my own User class I refactored the code to use my User class:</p> <pre><code>package com.jane class User { transient springSecurityService String email String name String password Boolean isAgreeTerms = false Date agreeTermsDt Boolean isActive = false Boolean isBlocked = false Date dateCreated Integer createdBy = 0 Date lastUpdated Integer modifiedBy = 0 static transients = [ 'springSecurityService' ] static hasMany = [ userProductTier: UserProductTier ] static mapping = { id column: "userID" dateCreated column: 'createdDt' lastUpdated column: 'modifiedDT' } static constraints = { email blank: false, email: true, unique: true, size: 5..100 name blank: false, size: 3..50 password blank: false } void beforeInsert() { if ( isAgreeTerms ) { agreeTermsDt = new Date() } encodePassword() } def beforeUpdate() { if (isDirty('password')) { encodePassword() } } protected void encodePassword() { password = springSecurityService.encodePassword(password) } } </code></pre> <p>I then modified the config.groovy file to:</p> <pre><code>grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.jane.User' grails.plugin.springsecurity.userLookup.usernamePropertyName = 'email' grails.plugin.springsecurity.userLookup.enabledPropertyName = 'isActive' grails.plugin.springsecurity.userLookup.accountExpiredPropertyName = 'isBlocked' grails.plugin.springsecurity.userLookup.accountLockedPropertyName = 'isBlocked' grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.jane.UserRole' grails.plugin.springsecurity.authority.className = 'com.jane.Role' </code></pre> <p>I can create users fine, verify they are in the database, have verified that encodePassword is called once. But every time I try to login I get the following error:</p> <blockquote> <p>Sorry, we were not able to find a user with that username and password.</p> </blockquote> <p>And here is the service method to create users:</p> <pre><code>User createTeamLeader( String name, String email, String password, Boolean isAgreeTerms, Integer productTierId ) { User user = new User( name: name, email: email, password: password, isAgreeTerms: isAgreeTerms, isActive: true) UserProductTier userProductTier = new UserProductTier( productTierId: productTierId ) user.addToUserProductTier( userProductTier ) user.save() UserRole.create( user, Role.findByAuthority('ROLE_USER'), true ) UserRole.create( user, Role.findByAuthority('ROLE_LEAD'), true ) user } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload